metanorma 1.3.5 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4ccf8d6a09fd9345faa44ae7201b4f7ee8816a6f36245c26b2482abd3f7afa9
4
- data.tar.gz: 7997e0bea6b752e07f7db96f19b6d136b7a9740c046a0850022b477a2223a85b
3
+ metadata.gz: 1858cecb1db05debaa3cb36f970a2bcb76b403508067ea2fa8569720fd294a98
4
+ data.tar.gz: 90f6e4bca7bd431a9d40a989c77837e6cfa47a12e436e0934624592bac0707f0
5
5
  SHA512:
6
- metadata.gz: 162c6e5e79ff9f7f4f41b17444c68ec23168ee593173b72c251c8623f9a16916f6ae557bc581f39d220c2c6d68d6350c2e4f4de7c000a87e90f39bed7e825609
7
- data.tar.gz: a92a8a6ddd41e404cb6a1e00e0a0aaa2ecd645723486769b8656bb09e10f9e595a9df81231713224f6f9781d17c1c6943135d978b5865d0c02842b5e0ccbb84c
6
+ metadata.gz: 8aec70e8a44751d4ab8557b793718c0bd02be3d90715a0048864257a8faf4bf23a5f4b60b780cf6d24658179eb2ecb572bf8b870ca9313b5d6f70839d2df03a5
7
+ data.tar.gz: 58814116504a8ec8c80961e836adf50b7e50bc049d2a259031e7dc92b9a8f8909ddd8bbc26219197057a6e4a9dfec4ee05cb16144f1b69fdfdc66d46d9408e9b
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
  steps:
data/Gemfile CHANGED
@@ -6,6 +6,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}" }
6
6
 
7
7
  gemspec
8
8
 
9
- if File.exist? 'Gemfile.devel'
10
- eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
9
+ if File.exist? "Gemfile.devel"
10
+ eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
11
11
  end
@@ -91,7 +91,9 @@ module Metanorma
91
91
  private
92
92
 
93
93
  def parse_xml(file)
94
- xml = Nokogiri::XML File.read(file, encoding: "UTF-8")
94
+ xml = Nokogiri::XML File.read(file, encoding: "UTF-8") do |config|
95
+ config.huge
96
+ end
95
97
  if (b = xml.at("/xmlns:metanorma-collection/xmlns:bibdata"))
96
98
  bd = Relaton::Cli.parse_xml b
97
99
  end
@@ -11,17 +11,21 @@ module Metanorma
11
11
  xrefs = @isodoc.xref_init(@lang, @script, @isodoc, @isodoc.i18n, {})
12
12
  xrefs.parse xml
13
13
  xrefs.get.each_with_object({}) do |(k, v), ret|
14
- v[:type] ||= "clause"
15
- ret[v[:type]] ||= {}
16
- index = if v[:container] || v[:label].nil? || v[:label].empty?
17
- UUIDTools::UUID.random_create.to_s
18
- else v[:label]
19
- end
20
- ret[v[:type]][index] = k
21
- ret[v[:type]][v[:value]] = k if v[:value]
14
+ read_anchors1(k, v, ret)
22
15
  end
23
16
  end
24
17
 
18
+ def read_anchors1(key, val, ret)
19
+ val[:type] ||= "clause"
20
+ ret[val[:type]] ||= {}
21
+ index = if val[:container] || val[:label].nil? || val[:label].empty?
22
+ UUIDTools::UUID.random_create.to_s
23
+ else val[:label]
24
+ end
25
+ ret[val[:type]][index] = key
26
+ ret[val[:type]][val[:value]] = key if val[:value]
27
+ end
28
+
25
29
  # @param id [String]
26
30
  # @param read [Boolean]
27
31
  # @return [Array<String, nil>]
@@ -33,30 +37,36 @@ module Metanorma
33
37
 
34
38
  # @param bib [Nokogiri::XML::Element]
35
39
  # @param identifier [String]
36
- def update_bibitem(bib, identifier) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
40
+ def update_bibitem(bib, identifier) # rubocop:disable Metrics/AbcSize
37
41
  docid = bib&.at(ns("./docidentifier"))&.children&.to_xml
38
- unless @files[docid]
39
- error = "[metanorma] Cannot find crossreference to document #{docid} "\
40
- "in document #{identifier}."
41
- @log.add("Cross-References", nil, error)
42
- Util.log(error, :warning)
43
- return
44
- end
45
- id = bib["id"]
46
- newbib = @files[docid][:bibdata].dup
47
- newbib.name = "bibitem"
48
- newbib["id"] = id
49
- newbib["hidden"] = "true"
50
- newbib&.at("./*[local-name() = 'ext']")&.remove
42
+ return fail_update_bibitem(docid, identifier) unless @files[docid]
43
+
44
+ newbib = dup_bibitem(docid, bib)
51
45
  bib.replace(newbib)
52
46
  _file, url = targetfile(@files[docid], relative: true, read: false,
53
- doc: !@files[docid][:attachment])
47
+ doc: !@files[docid][:attachment])
54
48
  uri_node = Nokogiri::XML::Node.new "uri", newbib
55
49
  uri_node[:type] = "citation"
56
50
  uri_node.content = url
57
51
  newbib.at(ns("./docidentifier")).previous = uri_node
58
52
  end
59
53
 
54
+ def fail_update_bibitem(docid, identifier)
55
+ error = "[metanorma] Cannot find crossreference to document #{docid} "\
56
+ "in document #{identifier}."
57
+ @log.add("Cross-References", nil, error)
58
+ Util.log(error, :warning)
59
+ end
60
+
61
+ def dup_bibitem(docid, bib)
62
+ newbib = @files[docid][:bibdata].dup
63
+ newbib.name = "bibitem"
64
+ newbib["hidden"] = "true"
65
+ newbib&.at("./*[local-name() = 'ext']")&.remove
66
+ newbib["id"] = bib["id"]
67
+ newbib
68
+ end
69
+
60
70
  # Resolves direct links to other files in collection
61
71
  # (repo(current-metanorma-collection/x),
62
72
  # and indirect links to other files in collection
@@ -67,7 +77,7 @@ module Metanorma
67
77
  # @param internal_refs [Hash{String=>Hash{String=>String}] schema name to anchor to filename
68
78
  # @return [String] XML content
69
79
  def update_xrefs(file, identifier, internal_refs)
70
- docxml = Nokogiri::XML(file)
80
+ docxml = Nokogiri::XML(file) { |config| config.huge }
71
81
  update_indirect_refs_to_docs(docxml, internal_refs)
72
82
  add_document_suffix(identifier, docxml)
73
83
  update_direct_refs_to_docs(docxml, identifier)
@@ -106,12 +116,18 @@ module Metanorma
106
116
  # Preferably with anchor, and is a job to realise dynamic lookup
107
117
  # of localities.
108
118
  def update_direct_refs_to_docs(docxml, identifier)
119
+ erefs = docxml.xpath(ns("//eref"))
120
+ .each_with_object({ citeas: {}, bibitemid: {} }) do |i, m|
121
+ m[:citeas][i["citeas"]] = true
122
+ m[:bibitemid][i["bibitemid"]] = true
123
+ end
109
124
  docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |b|
110
125
  docid = b&.at(ns("./docidentifier[@type = 'repository']"))&.text
111
126
  next unless docid && %r{^current-metanorma-collection/}.match(docid)
112
127
 
113
128
  update_bibitem(b, identifier)
114
- update_anchors(b, docxml, docid)
129
+ docid = b&.at(ns("./docidentifier"))&.children&.to_xml or next
130
+ erefs[:citeas][docid] and update_anchors(b, docxml, docid)
115
131
  end
116
132
  end
117
133
 
@@ -128,6 +144,9 @@ module Metanorma
128
144
  def update_indirect_refs_to_docs1(docxml, schema, id, file)
129
145
  docxml.xpath(ns("//eref[@bibitemid = '#{schema}_#{id}']")).each do |e|
130
146
  e["citeas"] = file
147
+ if a = e.at(ns(".//locality[@type = 'anchor']/referenceFrom"))
148
+ a.children = "#{a.text}_#{Metanorma::Utils::to_ncname(file)}"
149
+ end
131
150
  end
132
151
  docid = docxml.at(ns("//bibitem[@id = '#{schema}_#{id}']/"\
133
152
  "docidentifier[@type = 'repository']")) or return
@@ -137,21 +156,19 @@ module Metanorma
137
156
 
138
157
  # update crossrefences to other documents, to include
139
158
  # disambiguating document suffix on id
140
- def update_anchors(bib, docxml, _id) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
141
- docid = bib&.at(ns("./docidentifier"))&.children.to_xml
159
+ def update_anchors(bib, docxml, docid) # rubocop:disable Metrics/AbcSize
142
160
  docxml.xpath("//xmlns:eref[@citeas = '#{docid}']").each do |e|
143
- if @files[docid]
144
- update_anchor_loc(bib, e, docid)
161
+ if @files[docid] then update_anchor_loc(bib, e, docid)
145
162
  else
146
- e << "<strong>** Unresolved reference to document #{docid}, "\
147
- "id #{e['bibitemid']}</strong>"
163
+ e << "<strong>** Unresolved reference to document #{docid} "\
164
+ "from eref</strong>"
148
165
  end
149
166
  end
150
167
  end
151
168
 
152
- def update_anchor_loc(bib, e, docid)
153
- loc = e.at(ns(".//locality[@type = 'anchor']")) or
154
- return update_anchor_create_loc(bib, e, docid)
169
+ def update_anchor_loc(bib, eref, docid)
170
+ loc = eref.at(ns(".//locality[@type = 'anchor']")) or
171
+ return update_anchor_create_loc(bib, eref, docid)
155
172
  document_suffix = Metanorma::Utils::to_ncname(docid)
156
173
  ref = loc.at(ns("./referenceFrom")) || return
157
174
  anchor = "#{ref.text}_#{document_suffix}"
@@ -164,18 +181,14 @@ module Metanorma
164
181
 
165
182
  # if there is a crossref to another document, with no anchor, retrieve the
166
183
  # anchor given the locality, and insert it into the crossref
167
- def update_anchor_create_loc(bib, eref, docid)
184
+ def update_anchor_create_loc(_bib, eref, docid)
168
185
  ins = eref.at(ns("./localityStack")) or return
169
186
  type = ins&.at(ns("./locality/@type"))&.text
170
187
  type = "clause" if type == "annex"
171
188
  ref = ins&.at(ns("./locality/referenceFrom"))&.text
172
189
  anchor = @files[docid][:anchors].dig(type, ref) or return
173
- ref_from = Nokogiri::XML::Node.new "referenceFrom", bib
174
- ref_from.content = anchor.sub(/^_/, "")
175
- locality = Nokogiri::XML::Node.new "locality", bib
176
- locality[:type] = "anchor"
177
- locality.add_child ref_from
178
- ins << locality
190
+ ins << "<locality type='anchor'><referenceFrom>#{anchor.sub(/^_/, '')}"\
191
+ "</referenceFrom></locality>"
179
192
  end
180
193
 
181
194
  # gather internal bibitem references
@@ -186,7 +199,7 @@ module Metanorma
186
199
  file, = targetfile(x, read: true)
187
200
  Nokogiri::XML(file)
188
201
  .xpath(ns("//bibitem[@type = 'internal']/"\
189
- "docidentifier[@type = 'repository']")).each do |d|
202
+ "docidentifier[@type = 'repository']")).each do |d|
190
203
  a = d.text.split(%r{/}, 2)
191
204
  a.size > 1 or next
192
205
  refs[a[0]] ||= {}
@@ -211,10 +224,11 @@ module Metanorma
211
224
 
212
225
  def locate_internal_refs1(refs, identifier, filedesc)
213
226
  file, _filename = targetfile(filedesc, read: true)
214
- docxml = Nokogiri::XML(file)
227
+ xml = Nokogiri::XML(file) { |config| config.huge }
228
+ t = xml.xpath("//*/@id").each_with_object({}) { |i, x| x[i.text] = true }
215
229
  refs.each do |schema, ids|
216
- ids.each_key do |id|
217
- n = docxml.at("//*[@id = '#{id}']") and
230
+ ids.keys.select { |id| t[id] }.each do |id|
231
+ n = xml.at("//*[@id = '#{id}']") and
218
232
  n.at("./ancestor-or-self::*[@type = '#{schema}']") and
219
233
  refs[schema][id] = identifier
220
234
  end
@@ -27,8 +27,41 @@ module Metanorma
27
27
  files[identifier][:anchors] = read_anchors(xml)
28
28
  files[identifier][:bibdata] = xml.at(ns("//bibdata"))
29
29
  end
30
+ files[identifier][:bibitem] = files[identifier][:bibdata].dup
31
+ files[identifier][:bibitem].name = "bibitem"
32
+ files[identifier][:bibitem]["hidden"] = "true"
33
+ files[identifier][:bibitem]&.at("./*[local-name() = 'ext']")&.remove
30
34
  end
31
- files
35
+ add_section_split(files)
36
+ end
37
+
38
+ def add_section_split(files)
39
+ files.keys.each_with_object({}) do |k, m|
40
+ if files[k][:sectionsplit] == "true" && !files[k]["attachment"]
41
+ sectionsplit(files[k][:rel_path]).each_with_index do |f1, i|
42
+ m[k + f1[:title]] =
43
+ { parentid: k, presentationxml: true, type: "fileref",
44
+ rel_path: f1[:url], out_path: File.basename(f1[:url]),
45
+ anchors: read_anchors(Nokogiri::XML(File.read(f1[:url]))),
46
+ bibdata: files[k][:bibdata], ref: f1[:url] }
47
+ m[k + f1[:title]][:bare] = true unless i.zero?
48
+ end
49
+ m[k] = files[k]
50
+ else
51
+ m[k] = files[k]
52
+ end
53
+ end
54
+ end
55
+
56
+ def sectionsplit(file)
57
+ Compile.new.compile(
58
+ file, { format: :asciidoc, extension_keys: [:presentation] }
59
+ .merge(@compile_options)
60
+ )
61
+ r = file.sub(/\.xml$/, ".presentation.xml")
62
+ @isodoc.sectionsplit(
63
+ Nokogiri::XML(File.read(r)), File.basename(r), File.dirname(r)
64
+ ).sort_by { |f| f[:order] }
32
65
  end
33
66
 
34
67
  # rel_path is the source file address, determined relative to the YAML.
@@ -44,6 +77,9 @@ module Metanorma
44
77
  { type: "id", ref: ref["id"] }
45
78
  end
46
79
  ret[:attachment] = ref["attachment"] if ref["attachment"]
80
+ ret[:sectionsplit] = ref["sectionsplit"] if ref["sectionsplit"]
81
+ ret[:presentationxml] = ref["presentation-xml"] if ref["presentation-xml"]
82
+ ret[:bareafterfirst] = ref["bare-after-first"] if ref["bare-after-first"]
47
83
  ret
48
84
  end
49
85
 
@@ -95,22 +131,50 @@ module Metanorma
95
131
  end
96
132
 
97
133
  # compile and output individual file in collection
134
+ # warn "metanorma compile -x html #{f.path}"
98
135
  def file_compile(file, filename, identifier)
99
- # warn "metanorma compile -x html #{f.path}"
100
- Array(@directives).include?("presentation-xml") and
101
- @compile_options.merge!(passthrough_presentation_xml: true)
102
136
  c = Compile.new
103
- c.compile file.path, { format: :asciidoc,
104
- extension_keys: @format }.merge(@compile_options)
137
+ c.compile file.path, { format: :asciidoc, extension_keys: @format }
138
+ .merge(compile_options(identifier))
105
139
  @files[identifier][:outputs] = {}
140
+ file_compile_formats(file, filename, identifier, c)
141
+ end
142
+
143
+ def compile_options(identifier)
144
+ ret = @compile_options.dup
145
+ Array(@directives).include?("presentation-xml") ||
146
+ @files[identifier][:presentationxml] and
147
+ ret.merge!(passthrough_presentation_xml: true)
148
+ @files[identifier][:sectionsplit] == "true" and
149
+ ret.merge!(sectionsplit: "true")
150
+ @files[identifier][:bare] == true and
151
+ ret.merge!(bare: true)
152
+ ret
153
+ end
154
+
155
+ def file_compile_formats(file, filename, identifier, compile)
106
156
  @format.each do |e|
107
- ext = c.processor.output_formats[e]
108
- fn = File.basename(filename).sub(/(?<=\.)[^\.]+$/, ext.to_s)
109
- FileUtils.cp file.path.sub(/\.xml$/, ".#{ext}"), File.join(@outdir, fn)
110
- @files[identifier][:outputs][e] = File.join(@outdir, fn)
157
+ ext = compile.processor.output_formats[e]
158
+ fn = File.basename(filename).sub(/(?<=\.)[^.]+$/, ext.to_s)
159
+ if /html$/.match?(ext) && @files[identifier][:sectionsplit]
160
+ # file_sectionsplit_copy(file, fn, identifier, ext, e)
161
+ else
162
+ FileUtils.cp file.path.sub(/\.xml$/, ".#{ext}"),
163
+ File.join(@outdir, fn)
164
+ @files[identifier][:outputs][e] = File.join(@outdir, fn)
165
+ end
111
166
  end
112
167
  end
113
168
 
169
+ def file_sectionsplit_copy(file, base, identifier, ext, format)
170
+ dir = file.path.sub(/\.xml$/, ".#{ext}_collection")
171
+ files = Dir.glob("#{dir}/*.#{ext}")
172
+ FileUtils.cp files, @outdir
173
+ cover = File.join(@outdir, base.sub(/\.html$/, ".index.html"))
174
+ FileUtils.cp File.join(dir, "index.html"), cover
175
+ @files[identifier][:outputs][format] = cover
176
+ end
177
+
114
178
  def copy_file_to_dest(fileref)
115
179
  dest = File.join(@outdir, fileref[:out_path])
116
180
  FileUtils.mkdir_p(File.dirname(dest))
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative "util"
3
4
 
4
5
  module Metanorma
@@ -48,6 +49,8 @@ module Metanorma
48
49
  h = { "identifier" => dr.at("identifier").children.to_xml }
49
50
  dr[:fileref] and h["fileref"] = dr[:fileref]
50
51
  h["attachment"] = dr[:attachment] if dr[:attachment]
52
+ h["sectionsplit"] = dr[:sectionsplit] if dr[:sectionsplit]
53
+ h["presentation-xml"] = dr[:presentationxml] if dr[:presentationxml]
51
54
  h
52
55
  end
53
56
  end
@@ -59,7 +62,7 @@ module Metanorma
59
62
  @manifest.each { |mnf| mnf.collection = col }
60
63
  end
61
64
 
62
- # @param dir [String] path to coolection
65
+ # @param dir [String] path to collection
63
66
  # @return [Hash<String, Metanorma::Document>]
64
67
  def documents(dir = "")
65
68
  docs = @docref.each_with_object({}) do |dr, m|
@@ -116,6 +119,9 @@ module Metanorma
116
119
  def docref_to_xml_attrs(elem, docref)
117
120
  elem[:fileref] = @disambig.source2dest_filename(docref["fileref"])
118
121
  elem[:attachment] = docref["attachment"] if docref["attachment"]
122
+ elem[:sectionsplit] = docref["sectionsplit"] if docref["sectionsplit"]
123
+ elem[:presentationxml] = "true" if docref["presentation-xml"] &&
124
+ docref["presentation-xml"] == "true" || docref["presentation-xml"] == true
119
125
  if collection.directives.include?("documents-inline")
120
126
  id = collection.documents.find_index do |k, _|
121
127
  k == docref["identifier"]
@@ -35,7 +35,7 @@ module Metanorma
35
35
 
36
36
  @outdir = options[:output_folder]
37
37
  @coverpage = options[:coverpage]
38
- @format = options[:format]
38
+ @format = Util.sort_extensions_execution(options[:format])
39
39
  @compile_options = options[:compile] || {}
40
40
  @log = options[:log]
41
41
  @documents = collection.documents
@@ -70,7 +70,7 @@ module Metanorma
70
70
  ext = e == :presentation ? "presentation.xml" : e.to_s
71
71
  out = col.clone
72
72
  out.directives << "documents-inline"
73
- out.documents.keys.each do |id|
73
+ out.documents.each_key do |id|
74
74
  next if @files[id][:attachment]
75
75
 
76
76
  filename = @files[id][:outputs][e]
@@ -216,6 +216,14 @@ module Metanorma
216
216
 
217
217
  private
218
218
 
219
+ def format_sort(formats)
220
+ ret = []
221
+ formats.include?(:xml) and ret << :xml
222
+ formats.include?(:presentation) and ret << :presentation
223
+ a = %i(presentation xml)
224
+ ret + formats.reject { |i| a.include? i }
225
+ end
226
+
219
227
  # @param options [Hash]
220
228
  # @raise [ArgumentError]
221
229
  def check_options(options)
@@ -6,6 +6,7 @@ require "fontist"
6
6
  require "fontist/manifest/install"
7
7
  require_relative "compile_validate"
8
8
  require_relative "fontist_utils"
9
+ require_relative "util"
9
10
 
10
11
  module Metanorma
11
12
  class Compile
@@ -35,7 +36,7 @@ module Metanorma
35
36
  end
36
37
 
37
38
  def xml_options_extract(file)
38
- xml = Nokogiri::XML(file)
39
+ xml = Nokogiri::XML(file) { |config| config.huge }
39
40
  if xml.root
40
41
  @registry.root_tags.each do |k, v|
41
42
  return { type: k } if v == xml.root.name
@@ -111,7 +112,7 @@ module Metanorma
111
112
  def relaton_export(isodoc, options)
112
113
  return unless options[:relaton]
113
114
 
114
- xml = Nokogiri::XML(isodoc)
115
+ xml = Nokogiri::XML(isodoc) { |config| config.huge }
115
116
  bibdata = xml.at("//bibdata") || xml.at("//xmlns:bibdata")
116
117
  # docid = bibdata&.at("./xmlns:docidentifier")&.text || options[:filename]
117
118
  # outname = docid.sub(/^\s+/, "").sub(/\s+$/, "").gsub(/\s+/, "-") + ".xml"
@@ -135,7 +136,7 @@ module Metanorma
135
136
  end
136
137
  FileUtils.rm_rf dirname
137
138
  FileUtils.mkdir_p dirname
138
- xml = Nokogiri::XML(isodoc)
139
+ xml = Nokogiri::XML(isodoc) { |config| config.huge }
139
140
  sourcecode_export(xml, dirname) if extract_types.include? :sourcecode
140
141
  image_export(xml, dirname) if extract_types.include? :image
141
142
  requirement_export(xml, dirname) if extract_types.include? :requirement
@@ -181,17 +182,6 @@ module Metanorma
181
182
  end
182
183
  end
183
184
 
184
- # dependency ordering
185
- def sort_extensions_execution(ext)
186
- case ext
187
- when :xml then 0
188
- when :rxl then 1
189
- when :presentation then 2
190
- else
191
- 99
192
- end
193
- end
194
-
195
185
  def wrap_html(options, file_extension, outfilename)
196
186
  if options[:wrapper] && /html$/.match(file_extension)
197
187
  outfilename = outfilename.sub(/\.html$/, "")
@@ -206,20 +196,10 @@ module Metanorma
206
196
  f = change_output_dir options
207
197
  xml_name = f.sub(/\.[^.]+$/, ".xml")
208
198
  presentationxml_name = f.sub(/\.[^.]+$/, ".presentation.xml")
209
- extensions.sort do |a, b|
210
- sort_extensions_execution(a) <=> sort_extensions_execution(b)
211
- end.each do |ext|
212
- isodoc_options = @processor.extract_options(file)
213
- isodoc_options[:datauriimage] = true if options[:datauriimage]
214
- isodoc_options[:sourcefilename] = options[:filename]
215
- isodoc_options[:bare] = options[:bare]
199
+ Util.sort_extensions_execution(extensions).each do |ext|
216
200
  file_extension = @processor.output_formats[ext]
217
201
  outfilename = f.sub(/\.[^.]+$/, ".#{file_extension}")
218
- if ext == :pdf
219
- font_locations = FontistUtils.fontist_font_locations(@processor, options)
220
- font_locations and
221
- isodoc_options[:mn2pdf] = { font_manifest_file: font_locations.path }
222
- end
202
+ isodoc_options = get_isodoc_options(file, options, ext)
223
203
  if ext == :rxl
224
204
  options[:relaton] = outfilename
225
205
  relaton_export(isodoc, options)
@@ -231,12 +211,7 @@ module Metanorma
231
211
  @processor.output(nil, presentationxml_name, outfilename, ext, isodoc_options) :
232
212
  @processor.output(isodoc, xml_name, outfilename, ext, isodoc_options)
233
213
  rescue StandardError => e
234
- if e.message.include? "Fatal:"
235
- @errors << e.message
236
- else
237
- puts e.message
238
- puts e.backtrace.join("\n")
239
- end
214
+ isodoc_error_process(e)
240
215
  end
241
216
  end
242
217
  wrap_html(options, file_extension, outfilename)
@@ -245,6 +220,28 @@ module Metanorma
245
220
 
246
221
  private
247
222
 
223
+ def isodoc_error_process(err)
224
+ if err.message.include? "Fatal:"
225
+ @errors << err.message
226
+ else
227
+ puts err.message
228
+ puts err.backtrace.join("\n")
229
+ end
230
+ end
231
+
232
+ def get_isodoc_options(file, options, ext)
233
+ isodoc_options = @processor.extract_options(file)
234
+ isodoc_options[:datauriimage] = true if options[:datauriimage]
235
+ isodoc_options[:sourcefilename] = options[:filename]
236
+ isodoc_options[:bare] = options[:bare]
237
+ isodoc_options[:sectionsplit] = options[:sectionsplit]
238
+ if ext == :pdf
239
+ floc = FontistUtils.fontist_font_locations(@processor, options) and
240
+ isodoc_options[:mn2pdf] = { font_manifest_file: floc.path }
241
+ end
242
+ isodoc_options
243
+ end
244
+
248
245
  # @param options [Hash]
249
246
  # @return [String]
250
247
  def change_output_dir(options)
@@ -30,7 +30,9 @@ module Metanorma
30
30
 
31
31
  # raw XML file, can be used to put in entire file instead of just bibitem
32
32
  def raw_file(filename)
33
- doc = Nokogiri::XML(File.read(filename, encoding: "UTF-8"))
33
+ doc = Nokogiri::XML(File.read(filename, encoding: "UTF-8")) do |config|
34
+ config.huge
35
+ end
34
36
  new(doc, filename, raw: true)
35
37
  end
36
38
 
@@ -100,7 +102,9 @@ module Metanorma
100
102
  if @raw
101
103
  builder << @bibitem.root.to_xml
102
104
  else
103
- builder.send(type + "-standard") { |b| b << @bibitem.to_xml(bibdata: true) }
105
+ builder.send("#{type}-standard") do |b|
106
+ b << @bibitem.to_xml(bibdata: true)
107
+ end
104
108
  end
105
109
  end
106
110
  end
@@ -12,6 +12,23 @@ module Metanorma
12
12
  end
13
13
  end
14
14
 
15
+ # dependency ordering
16
+ def self.sort_extensions_execution_ord(ext)
17
+ case ext
18
+ when :xml then 0
19
+ when :rxl then 1
20
+ when :presentation then 2
21
+ else
22
+ 99
23
+ end
24
+ end
25
+
26
+ def self.sort_extensions_execution(ext)
27
+ ext.sort do |a, b|
28
+ sort_extensions_execution_ord(a) <=> sort_extensions_execution_ord(b)
29
+ end
30
+ end
31
+
15
32
  class DisambigFiles
16
33
  def initialize
17
34
  @seen_filenames = []
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.3.5".freeze
2
+ VERSION = "1.3.6".freeze
3
3
  end
data/metanorma.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.required_ruby_version = ">= 2.5.0"
24
24
 
25
25
  spec.add_runtime_dependency "asciidoctor"
26
- spec.add_runtime_dependency "fontist", "~> 1.8"
26
+ spec.add_runtime_dependency "fontist", "~> 1.9"
27
27
  spec.add_runtime_dependency "htmlentities"
28
28
  spec.add_runtime_dependency "metanorma-utils", "~> 1.2.0"
29
29
  spec.add_runtime_dependency "mn2pdf", "~> 1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-21 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.8'
33
+ version: '1.9'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.8'
40
+ version: '1.9'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: htmlentities
43
43
  requirement: !ruby/object:Gem::Requirement