metanorma 2.2.2 → 2.2.4

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: 6c21a32c429827b3a3f308801ec2e8617f2e30f2baf8c8e5e6c80f2c105b0ce2
4
- data.tar.gz: b59f55514b1413623471c7c408a7688a87513f03aca899afeb433372577f37e1
3
+ metadata.gz: b4efa4e511db71c9743419f1a8fa69e71f89ad55ba00a3c98f9786d95e53899a
4
+ data.tar.gz: e498bbfdc5b5a86f448acd94a85f1cb4b5660cd567daa8d9f216ebd47ef2e28e
5
5
  SHA512:
6
- metadata.gz: 06e63a51abf0ff822b2f6bed6cf51a1c0a55f08375aff1aec64d41016fd5c3f4d61ed21661911dee7bb9c4477a406b1a5bd125f95c2d00a9096415249cba24c5
7
- data.tar.gz: 78352215966b37d04fbb5cb0203bd65d725b63eade9652ecf2142ef4d9b594fe69229232de6e5796c44c782cef3763af4e5d31c2eee2a0f67e8ab3c66bc470da
6
+ metadata.gz: e3043c95ec435acae073b5023831cfc63c1557b1e87a6767ac169185c569f0534663bc7bc834d222a915bb8ba205c9763224207f6980299facdecc52bcf2e26b
7
+ data.tar.gz: 52541d4d6ba827aeeaf978b6c13e040c368386a10021881049d9144976304a3054a6fe4370da294220abe9d88577993b646e14e3fda8026b7b6e9d778e8fe9b4
data/README.adoc CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma.svg["Gem Version", link="https://rubygems.org/gems/metanorma"]
4
4
  image:https://github.com/metanorma/metanorma/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma/actions?workflow=rake"]
5
- image:https://codeclimate.com/github/metanorma/metanorma/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma"]
5
+ // image:https://codeclimate.com/github/metanorma/metanorma/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma"]
6
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma.svg["Pull Requests", link="https://github.com/metanorma/metanorma/pulls"]
7
7
  image:https://img.shields.io/github/commits-since/metanorma/metanorma/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma/releases"]
8
8
 
@@ -26,7 +26,6 @@ module Metanorma
26
26
  @disambig = Util::DisambigFiles.new
27
27
  @manifest = parent.manifest
28
28
  read_files(@manifest.entry, parent.manifest)
29
- #warn pp @files
30
29
  end
31
30
 
32
31
  def read_files(entries, parent)
@@ -4,7 +4,7 @@ module Metanorma
4
4
  # Resolves references to other files in the collection. Three routines:
5
5
  # 1. Eref to a document that has been split into multiple documents
6
6
  # (sectionsplit) are resolved to direct eref to the split document
7
- # 2. Indirect erefs to a file anchor in an unknwon file in the collection
7
+ # 2. Indirect erefs to a file anchor in an unknown file in the collection
8
8
  # (bibitem[@type = 'internal'] ) are resolved to direct eref to the
9
9
  # containing document
10
10
  # 3. Direct erefs to other files in collection
@@ -11,7 +11,6 @@ module Metanorma
11
11
  # warn "metanorma compile -x html #{f.path}"
12
12
  def file_compile(file, filename, identifier)
13
13
  @files.get(identifier, :sectionsplit) and return
14
- #require "debug"; binding.b
15
14
  opts = {
16
15
  format: :asciidoc,
17
16
  extension_keys: @files.get(identifier, :format),
@@ -181,9 +181,12 @@ module Metanorma
181
181
  # collection manifest
182
182
  def coverpage
183
183
  @coverpage or return
184
+
185
+ @coverpage_path = Util::rel_path_resolve(@dirname, @coverpage)
184
186
  warn "\n\n\n\n\nCoverpage: #{DateTime.now.strftime('%H:%M:%S')}"
187
+
185
188
  File.open(File.join(@outdir, "index.html"), "w:UTF-8") do |f|
186
- f.write @isodoc.populate_template(File.read(@coverpage))
189
+ f.write @isodoc.populate_template(File.read(@coverpage_path))
187
190
  end
188
191
  end
189
192
  end
@@ -11,21 +11,31 @@ module Metanorma
11
11
  end
12
12
 
13
13
  def svgmap_resolve(docxml, docid, presxml)
14
+ ids, docxml, isodoc, tag = svgmap_resolve_prep(docxml, docid, presxml)
15
+ docxml.xpath(ns("//svgmap//#{tag}")).each do |e|
16
+ svgmap_resolve_eref(e, isodoc, docxml, ids, presxml)
17
+ end
18
+ svgmap_fmt_prefix_remove(docxml)
19
+ Vectory::SvgMapping.new(docxml, "").call
20
+ docxml.xpath(ns("//svgmap")).each { |s| isodoc.svgmap_extract(s) }
21
+ end
22
+
23
+ def svgmap_resolve_prep(docxml, docid, presxml)
14
24
  ids = @files.get(docid, :ids)
15
25
  docxml = svg_unnest(svg_datauri(docxml, docid))
16
26
  isodoc = IsoDoc::PresentationXMLConvert.new({})
17
27
  isodoc.bibitem_lookup(docxml)
18
28
  tag = presxml ? "fmt-eref" : "eref"
19
- docxml.xpath(ns("//svgmap//#{tag}")).each do |e|
20
- svgmap_resolve_eref(e, isodoc, docxml, ids, presxml)
21
- end
22
- docxml.xpath(ns("//svgmap/target")).each do |t| # undo Presentation XML: Vectory takes eref not fmt-eref
29
+ [ids, docxml, isodoc, tag]
30
+ end
31
+
32
+ # undo Presentation XML update: Vectory takes eref not fmt-eref
33
+ def svgmap_fmt_prefix_remove(docxml)
34
+ docxml.xpath(ns("//svgmap/target")).each do |t|
23
35
  n = t.at(ns(".//fmt-link | .//fmt-xref | .//fmt-eref")) or next
24
36
  n.name = n.name.sub(/^fmt-/, "")
25
37
  t.children = n
26
38
  end
27
- Vectory::SvgMapping.new(docxml, "").call
28
- docxml.xpath(ns("//svgmap")).each { |s| isodoc.svgmap_extract(s) }
29
39
  end
30
40
 
31
41
  def svg_unnest(docxml)
@@ -72,7 +72,7 @@ module Metanorma
72
72
  def block?(node)
73
73
  %w(p table formula admonition ol ul dl figure quote sourcecode example
74
74
  pre note pagebreak hr bookmark requirement recommendation permission
75
- svgmap inputform toc passthrough review imagemap).include?(node.name)
75
+ svgmap inputform toc passthrough annotation imagemap).include?(node.name)
76
76
  end
77
77
 
78
78
  def conflate_floatingtitles(nodes)
@@ -151,7 +151,7 @@ module Metanorma
151
151
  def create_sectionfile(xml, out, file, chunks, parentnode)
152
152
  ins = out.at(ns("//metanorma-extension")) || out.at(ns("//bibdata"))
153
153
  sectionfile_insert(ins, chunks, parentnode)
154
- sectionfile_fn_filter(sectionfile_review_filter(out))
154
+ sectionfile_fn_filter(sectionfile_annotation_filter(out))
155
155
  Metanorma::Collection::XrefProcess::xref_process(out, xml, @key,
156
156
  @ident, @isodoc, true)
157
157
  outname = "#{file}.xml"
@@ -211,34 +211,35 @@ module Metanorma
211
211
  fnlabel.children = @isodoc_presxml.fn_body_label(fnbody)
212
212
  end
213
213
 
214
- # map fmt-review-body/@id = fmt-review-{start/end}/@target
215
- # to fmt-review-{stary/end}
216
- def sectionfile_review_filter_prep(xml)
217
- xml.xpath(ns("//fmt-review-start | //fmt-review-end"))
214
+ # map fmt-annotation-body/@id = fmt-annotation-{start/end}/@target
215
+ # to fmt-annotation-{start/end}
216
+ def sectionfile_annotation_filter_prep(xml)
217
+ xml.xpath(ns("//fmt-annotation-start | //fmt-annotation-end"))
218
218
  .each_with_object({}) do |f, m|
219
219
  m[f["target"]] ||= []
220
220
  m[f["target"]] << f
221
221
  end
222
222
  end
223
223
 
224
- def sectionfile_review_filter(xml)
225
- ids = sectionfile_review_filter_prep(xml)
226
- xml.root.xpath(ns("./review-container/fmt-review-body")).each do |f|
224
+ def sectionfile_annotation_filter(xml)
225
+ ids = sectionfile_annotation_filter_prep(xml)
226
+ xml.root.xpath(ns("./annotation-container/fmt-annotation-body"))
227
+ .each do |f|
227
228
  ids.has_key?(f["id"]) or f.remove
228
229
  end
229
- xml.root.xpath(ns("./review-container/fmt-review-body"))
230
+ xml.root.xpath(ns("./annotation-container/fmt-annotation-body"))
230
231
  .each_with_index do |fnbody, i|
231
- sectionfile_review_filter_renumber(fnbody, i, ids)
232
+ sectionfile_annotation_filter_renumber(fnbody, i, ids)
232
233
  end
233
234
  xml
234
235
  end
235
236
 
236
- def sectionfile_review_filter_renumber(fnbody, _idx, ids)
237
+ def sectionfile_annotation_filter_renumber(fnbody, _idx, ids)
237
238
  ids[fnbody["id"]].each do |f|
238
239
  case f.name
239
- when "fmt-review-start"
240
+ when "fmt-annotation-start"
240
241
  f.children = @isodoc_presxml.comment_bookmark_start_label(f)
241
- when "fmt-review-end"
242
+ when "fmt-annotation-end"
242
243
  f.children = @isodoc_presxml.comment_bookmark_end_label(f)
243
244
  end
244
245
  end
@@ -75,7 +75,7 @@ module Metanorma
75
75
  xref_prefix_key(x, key, indirect)
76
76
  x["bibitemid"] = x["target"]
77
77
  m[x["bibitemid"]] = true
78
- xref_to_internal_eref_anchor(x, key, bibitems,
78
+ xref_to_internal_eref_anchor(x, bibitems,
79
79
  xml.root["document_suffix"], presxml)
80
80
  end.keys
81
81
  end
@@ -87,8 +87,9 @@ module Metanorma
87
87
  [bibitems, indirect_bibitems]
88
88
  end
89
89
 
90
- def xref_to_internal_eref_anchor(xref, key, bibitems, document_suffix, presxml)
90
+ def xref_to_internal_eref_anchor(xref, bibitems, document_suffix, presxml)
91
91
  t = xref["target"]
92
+ key = xref["type"]
92
93
  if d = bibitems[t]&.at(ns("./docidentifier[@type = 'repository']"))
93
94
  m = %r{^([^/]+)}.match(d.text) and
94
95
  t.sub!(%r(#{m[0]}_), "")
@@ -62,6 +62,7 @@ module Metanorma
62
62
 
63
63
  # Step 3: Determine which output formats to generate
64
64
  extensions = get_extensions(options)
65
+ @extensions = extensions # Capture extensions for later access
65
66
  return nil unless extensions
66
67
 
67
68
  # Step 4: Extract information from Semantic XML if requested
@@ -184,8 +185,8 @@ module Metanorma
184
185
  end
185
186
 
186
187
  def process_input_adoc_overrides(attrs, options)
187
- Metanorma::TasteRegister.instance.available_tastes.include?(options[:supplied_type]) or
188
- return
188
+ Metanorma::TasteRegister.instance.available_tastes
189
+ .include?(options[:supplied_type]) or return
189
190
  c = Metanorma::TasteRegister.get(options[:supplied_type])
190
191
  c.process_input_adoc_overrides(attrs, options)
191
192
  end
@@ -203,9 +204,24 @@ module Metanorma
203
204
  file = read_file(filename)
204
205
  file = process_input_adoc_hdr(file, options)
205
206
  file = process_input_adoc_includes(file, filename)
207
+ update_options_after_preprocessing(file, options)
206
208
  [file, @processor.input_to_isodoc(file, filename, options)]
207
209
  end
208
210
 
211
+ # need to update options, for any content added;
212
+ # e.g. new attributes from Metanorma taste
213
+ def update_options_after_preprocessing(file, options)
214
+ new_options = {}
215
+ Tempfile.open(["tmp", ".adoc"], encoding: "UTF-8") do |f|
216
+ f.write(file)
217
+ f.close
218
+ new_options = extract_options(f, {})
219
+ end
220
+ new_options.compact!
221
+ new_options.delete(:filename)
222
+ options.merge!(new_options)
223
+ end
224
+
209
225
  def process_input_xml(filename, _options)
210
226
  Util.log("[metanorma] Processing: Metanorma XML input.", :info)
211
227
  # TODO NN: this is a hack -- we should provide/bridge the
@@ -216,5 +232,23 @@ module Metanorma
216
232
  def read_file(filename)
217
233
  File.read(filename, encoding: "utf-8").gsub("\r\n", "\n")
218
234
  end
235
+
236
+ # Returns a mapping of format types to file suffixes based on the
237
+ # extensions that were determined during compilation.
238
+ # This method is only available after compile() has been called and
239
+ # reached Step 3 where extensions are finalized.
240
+ #
241
+ # @return [Hash] mapping of format symbols to file extensions
242
+ # e.g., { html: "html", doc: "doc", pdf: "pdf" }
243
+ # @return [Hash] empty hash if extensions haven't been captured yet
244
+ def output_format_mapping
245
+ return {} unless @extensions && @processor
246
+
247
+ @extensions.each_with_object({}) do |ext, mapping|
248
+ if @processor.output_formats[ext]
249
+ mapping[ext] = @processor.output_formats[ext]
250
+ end
251
+ end
252
+ end
219
253
  end
220
254
  end
@@ -44,6 +44,7 @@ module Metanorma
44
44
  end
45
45
 
46
46
  def extract_dir_options(options, options_in_file, filename)
47
+ filename.is_a?(Tempfile) and return
47
48
  dir = filename.sub(%r(/[^/]+$), "/")
48
49
  options_in_file[:relaton] and
49
50
  options[:relaton] ||= File.join(dir,
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.2.2".freeze
2
+ VERSION = "2.2.4".freeze
3
3
  end
data/metanorma.gemspec CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
  # spec.add_dependency "metanorma-standoc"
39
39
 
40
40
  spec.add_development_dependency "debug"
41
- spec.add_development_dependency "equivalent-xml", "~> 0.6"
41
+ spec.add_development_dependency "equivalent-xml"
42
42
  spec.add_development_dependency "metanorma-iso"
43
43
  spec.add_development_dependency "mnconvert"
44
44
  spec.add_development_dependency "pry"
@@ -49,5 +49,5 @@ Gem::Specification.new do |spec|
49
49
  spec.add_development_dependency "rubocop-performance"
50
50
  spec.add_development_dependency "sassc-embedded", "~> 1"
51
51
  spec.add_development_dependency "simplecov", "~> 0.15"
52
- spec.add_development_dependency "xml-c14n"
52
+ spec.add_development_dependency "canon"
53
53
  end
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: 2.2.2
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-05 00:00:00.000000000 Z
11
+ date: 2025-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: equivalent-xml
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: '0.6'
145
+ version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: '0.6'
152
+ version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: metanorma-iso
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -291,7 +291,7 @@ dependencies:
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0.15'
293
293
  - !ruby/object:Gem::Dependency
294
- name: xml-c14n
294
+ name: canon
295
295
  requirement: !ruby/object:Gem::Requirement
296
296
  requirements:
297
297
  - - ">="