metanorma 2.0.11 → 2.1.2

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: 7fa8deddc619f4709beefe82cce7b877ea9402963b037b9c84770b3ca0c14a90
4
- data.tar.gz: 185080156bee2c43d4a5b87e0bd0ba4925569e94c2f19eeeed2e82d6bb563ec3
3
+ metadata.gz: 61f89a2c7a4e3b018425e87162e66fa5e1a8c20a4cf546ff477fd525be04e455
4
+ data.tar.gz: 3af3ca357995db324f7f8f844ff01a0651e0ba9c4fcd4c4f585c15baa4f33269
5
5
  SHA512:
6
- metadata.gz: fe6ac88b648d30a9f82c5d5bc9b4c14b021204126fc5513772bfa2263519c767e19a395ca26d4f82f2cbd41ca014549d3919b4083832cd282865a70a4105064c
7
- data.tar.gz: f3937b78290728d24cbd89245f696c6163ff60f2e4b1b0bc645fa63aec27673d971484a507b15101b1a1c7e3b4b86442c4edf6784913873b5cceed931e7a948c
6
+ metadata.gz: d8128a3b6b239af0af4e7cef15b5429ac3d4294c4407bcd618d22413ac49f98ee38dcba53c6e78604399321c059f33f93ee4a42d437b258cb5823e609936267c
7
+ data.tar.gz: 90bcc67a7a066eb8b84bd7abe26398d4cf7513fd8a804fa0cd60944d709ca8352ecfdbc94cc8a02c7d6e423cfddb9abc0754db3e2ecd1d54f3eb95fd64701e37
@@ -214,6 +214,9 @@ module Metanorma
214
214
  # @param fileref [String]
215
215
  # @return [String]
216
216
  def resolve_fileref(ref_folder, fileref)
217
+ warn ref_folder
218
+ warn fileref
219
+ #require "debug"; binding.b
217
220
  unless @fileref_resolver
218
221
  (Pathname.new fileref).absolute? or
219
222
  fileref = File.join(ref_folder, fileref)
@@ -9,7 +9,6 @@ require_relative "manifest"
9
9
  module Metanorma
10
10
  class Collection
11
11
  module Config
12
- require "shale/adapter/nokogiri"
13
12
  Lutaml::Model::Config.configure do |config|
14
13
  config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
15
14
  end
@@ -71,7 +70,7 @@ module Metanorma
71
70
  end
72
71
 
73
72
  def manifest_from_xml(model, node)
74
- model.manifest = Manifest.from_xml(node.node.to_xml)
73
+ model.manifest = Manifest.from_xml(node.to_xml)
75
74
  end
76
75
 
77
76
  def manifest_to_xml(model, parent, doc)
@@ -80,7 +79,7 @@ module Metanorma
80
79
  end
81
80
 
82
81
  def prefatory_from_xml(model, node)
83
- model.prefatory_content = node
82
+ model.prefatory_content = node.children.map(&:to_xml).join
84
83
  end
85
84
 
86
85
  def prefatory_to_xml(model, parent, doc)
@@ -105,7 +104,7 @@ module Metanorma
105
104
  end
106
105
 
107
106
  def final_from_xml(model, node)
108
- model.final_content = node
107
+ model.final_content = node.children.map(&:to_xml).join
109
108
  end
110
109
 
111
110
  def directives_from_yaml(model, value)
@@ -15,7 +15,7 @@ module Metanorma
15
15
 
16
16
  def bibdata_from_xml(model, node)
17
17
  node and
18
- model.bibdata = Relaton::Cli.parse_xml(node.node.adapter_node)
18
+ model.bibdata = Relaton::Cli.parse_xml(node.adapter_node)
19
19
  end
20
20
 
21
21
  def bibdata_to_xml(model, parent, doc)
@@ -7,7 +7,6 @@ require_relative "bibdata"
7
7
  module Metanorma
8
8
  class Collection
9
9
  module Config
10
- require "shale/adapter/nokogiri"
11
10
  Lutaml::Model::Config.configure do |config|
12
11
  config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
13
12
  end
@@ -14,6 +14,7 @@ module Metanorma
14
14
  # @param docref [Array<Hash{String=>String}>]
15
15
  # @param manifest [Array<Metanorma::Collection::Manifest>]
16
16
  def initialize(config, collection, dir)
17
+ #require "debug"; binding.b
17
18
  @collection = collection
18
19
  @dir = dir
19
20
  @disambig = ::Metanorma::Collection::Util::DisambigFiles.new
@@ -21,6 +22,7 @@ module Metanorma
21
22
  end
22
23
 
23
24
  def manifest_postprocess(config)
25
+ #require "debug"; binding.b
24
26
  manifest_bibdata(config)
25
27
  manifest_expand_yaml(config, @dir)
26
28
  manifest_compile_adoc(config)
@@ -94,6 +96,7 @@ module Metanorma
94
96
 
95
97
  def manifest_filexist(config)
96
98
  if config.file
99
+ #require "debug"; binding.b
97
100
  file = @collection.class.resolve_fileref(@dir, config.file)
98
101
  @collection.class.check_file_existence(file)
99
102
  config.file = Pathname.new(file).relative_path_from(Pathname.new(@dir))
@@ -108,6 +111,7 @@ module Metanorma
108
111
  currdir = dir
109
112
  /\.ya?ml$/.match?(e.file) and
110
113
  currdir = manifest_expand_yaml_entry(e, dir)
114
+ #require "debug"; binding.b
111
115
  manifest_expand_yaml(e, currdir)
112
116
  end
113
117
  config
@@ -118,8 +122,10 @@ module Metanorma
118
122
  currdir = File.dirname(f)
119
123
  @collection.class.check_file_existence(f)
120
124
  entry.file = nil
125
+ #require 'debug'; binding.b
121
126
  entry.entry = ::Metanorma::Collection::Config::Config.from_yaml(File.read(f)).manifest
122
127
  if currdir != dir
128
+ #require "debug"; binding.b
123
129
  prefix = Pathname.new(currdir).relative_path_from(Pathname.new(dir))
124
130
  update_filepaths(entry.entry, prefix.to_s)
125
131
  end
@@ -127,6 +133,7 @@ module Metanorma
127
133
  end
128
134
 
129
135
  def update_filepaths(entry, prefix)
136
+ #require "debug"; binding.b
130
137
  entry.file && !(Pathname.new entry.file).absolute? and
131
138
  entry.file = File.join(prefix, entry.file)
132
139
  entry.entry.each do |f|
@@ -16,20 +16,23 @@ module Metanorma
16
16
  # @return [String] XML content
17
17
  def update_xrefs(file, docid, internal_refs)
18
18
  xml, sso = update_xrefs_prep(file, docid)
19
+ #require "debug"; binding.b if /This document is also unrelated/.match?(xml.to_xml)
20
+ #warn (/fmt-title/.match?(xml.to_xml) ? "*** PRESENTATION" : "*** SEMANTIC")
19
21
  @nested || sso or
20
22
  Metanorma::Collection::XrefProcess::xref_process(xml, xml, nil, docid,
21
- @isodoc)
23
+ @isodoc, sso)
22
24
  @ncnames = {}
23
- @nested or update_indirect_refs_to_docs(xml, docid, internal_refs)
25
+ @nested or update_indirect_refs_to_docs(xml, docid, internal_refs, sso)
24
26
  @files.add_document_suffix(docid, xml)
25
- @nested or update_sectionsplit_refs_to_docs(xml, internal_refs)
26
- update_direct_refs_to_docs(xml, docid)
27
+ @nested or update_sectionsplit_refs_to_docs(xml, internal_refs, sso)
28
+ update_direct_refs_to_docs(xml, docid, sso)
27
29
  hide_refs(xml)
28
- sso and eref2link(xml)
29
- @nested or svgmap_resolve(xml, docid)
30
+ sso and eref2link(xml, sso)
31
+ @nested or svgmap_resolve(xml, docid, sso)
30
32
  xml.to_xml
31
33
  end
32
34
 
35
+ ## sso files are Presentation XML; otherwise, Semantic XML
33
36
  def update_xrefs_prep(file, docid)
34
37
  docxml = file.is_a?(String) ? Nokogiri::XML(file, &:huge) : file
35
38
  supply_repo_ids(docxml)
@@ -37,8 +40,8 @@ module Metanorma
37
40
  [docxml, sso]
38
41
  end
39
42
 
40
- def update_sectionsplit_refs_to_docs(docxml, internal_refs)
41
- Util::gather_citeases(docxml).each do |k, v|
43
+ def update_sectionsplit_refs_to_docs(docxml, internal_refs, presxml)
44
+ Util::gather_citeases(docxml, presxml).each do |k, v|
42
45
  (@files.get(k) && @files.get(k, :sectionsplit)) or next
43
46
  opts = { key: @files.get(k, :indirect_key),
44
47
  source_suffix: docxml.root["document_suffix"],
@@ -81,9 +84,9 @@ module Metanorma
81
84
  # Any erefs to that bibitem id are replaced with relative URL
82
85
  # Preferably with anchor, and is a job to realise dynamic lookup
83
86
  # of localities.
84
- def update_direct_refs_to_docs(docxml, identifier)
87
+ def update_direct_refs_to_docs(docxml, identifier, presxml)
85
88
  erefs, erefs_no_anchor, anchors, erefs1 =
86
- update_direct_refs_to_docs_prep(docxml)
89
+ update_direct_refs_to_docs_prep(docxml, presxml)
87
90
  docxml.xpath(ns("//bibitem")).each do |b|
88
91
  docid = b.at(ns("./docidentifier[@type = 'repository']")) or next
89
92
  strip_unresolved_repo_erefs(identifier, docid, erefs1, b) or next
@@ -96,8 +99,8 @@ module Metanorma
96
99
  end
97
100
 
98
101
  # Hash(docid) of arrays
99
- def update_direct_refs_to_docs_prep(docxml)
100
- erefs = Util::gather_citeases(docxml)
102
+ def update_direct_refs_to_docs_prep(docxml, presxml)
103
+ erefs = Util::gather_citeases(docxml, presxml)
101
104
  no_anchor = erefs.keys.each_with_object({}) { |k, m| m[k] = [] }
102
105
  anchors = erefs.keys.each_with_object({}) { |k, m| m[k] = [] }
103
106
  erefs.each do |k, v|
@@ -106,7 +109,8 @@ module Metanorma
106
109
  else no_anchor[k] << e end
107
110
  end
108
111
  end
109
- [erefs, no_anchor, anchors, Util::gather_bibitemids(docxml)]
112
+ #require "debug"; binding.b
113
+ [erefs, no_anchor, anchors, Util::gather_bibitemids(docxml, presxml)]
110
114
  end
111
115
 
112
116
  # strip erefs if they are repository erefs, but do not point to a document
@@ -124,8 +128,8 @@ module Metanorma
124
128
 
125
129
  # Resolve erefs to a container of ids in another doc,
126
130
  # to an anchor eref (direct link)
127
- def update_indirect_refs_to_docs(docxml, _docidentifier, internal_refs)
128
- bib, erefs, doc_suffix, doc_type, f = update_indirect_refs_prep(docxml)
131
+ def update_indirect_refs_to_docs(docxml, _docidentifier, internal_refs, presxml)
132
+ bib, erefs, doc_suffix, doc_type, f = update_indirect_refs_prep(docxml, presxml)
129
133
  internal_refs.each do |schema, ids|
130
134
  add_suffix = doc_suffix && doc_type && doc_type != schema
131
135
  ids.each do |id, file|
@@ -138,13 +142,14 @@ module Metanorma
138
142
  end
139
143
  end
140
144
 
141
- def update_indirect_refs_prep(docxml)
145
+ def update_indirect_refs_prep(docxml, presxml)
142
146
  @updated_anchors = {}
143
147
  @indirect_keys = {}
144
- [Util::gather_bibitems(docxml), Util::gather_bibitemids(docxml),
148
+ [Util::gather_bibitems(docxml), Util::gather_bibitemids(docxml, presxml),
145
149
  docxml.root["document_suffix"], docxml.root["type"], {}]
146
150
  end
147
151
 
152
+ # KILL
148
153
  def indirect_ref_key(schema, id, doc_suffix, doc_type)
149
154
  /^#{schema}_/.match?(id) and return id
150
155
  key = [schema, id, doc_suffix, doc_type].join("::")
@@ -168,6 +173,7 @@ module Metanorma
168
173
  end
169
174
  end
170
175
 
176
+ # KILL
171
177
  def indirect_ref_keyx(schema, id, doc_suffix, doc_type)
172
178
  /^#{schema}_/.match?(id) and return id
173
179
  ret = "#{schema}_#{id}"
@@ -15,6 +15,7 @@ module Metanorma
15
15
  format: :asciidoc,
16
16
  extension_keys: @format,
17
17
  output_dir: @outdir,
18
+ type: @flavor,
18
19
  }.merge(compile_options_update(identifier))
19
20
  @compile.compile file, opts
20
21
  @files.set(identifier, :outputs, {})
@@ -44,7 +44,7 @@ module Metanorma
44
44
  @compile.load_flavor(@flavor)
45
45
 
46
46
  # output processor for flavour
47
- @isodoc = Util::isodoc_create(@flavor, @lang, @scropt, @xml)
47
+ @isodoc = Util::isodoc_create(@flavor, @lang, @script, @xml)
48
48
  @outdir = dir_name_cleanse(options[:output_folder])
49
49
  @coverpage = options[:coverpage] || collection.coverpage
50
50
  @format = ::Metanorma::Util.sort_extensions_execution(options[:format])
@@ -10,13 +10,21 @@ module Metanorma
10
10
  datauri_encode(docxml, dir)
11
11
  end
12
12
 
13
- def svgmap_resolve(docxml, docid)
13
+ def svgmap_resolve(docxml, docid, presxml)
14
+ #require "debug"; binding.b
14
15
  ids = @files.get(docid, :ids)
15
16
  docxml = svg_unnest(svg_datauri(docxml, docid))
16
17
  isodoc = IsoDoc::PresentationXMLConvert.new({})
17
18
  isodoc.bibitem_lookup(docxml)
18
- docxml.xpath(ns("//svgmap//eref")).each do |e|
19
- svgmap_resolve_eref(e, isodoc, docxml, ids)
19
+ tag = presxml ? "fmt-eref" : "eref"
20
+ docxml.xpath(ns("//svgmap//#{tag}")).each do |e|
21
+ #require "debug"; binding.b
22
+ svgmap_resolve_eref(e, isodoc, docxml, ids, presxml)
23
+ end
24
+ docxml.xpath(ns("//svgmap/target")).each do |t| # undo Presentation XML: Vectory takes eref not fmt-eref
25
+ n = t.at(ns(".//fmt-link | .//fmt-xref | .//fmt-eref")) or next
26
+ n.name = n.name.sub(/^fmt-/, "")
27
+ t.children = n
20
28
  end
21
29
  Vectory::SvgMapping.new(docxml, "").call
22
30
  docxml.xpath(ns("//svgmap")).each { |s| isodoc.svgmap_extract(s) }
@@ -30,13 +38,13 @@ module Metanorma
30
38
  docxml
31
39
  end
32
40
 
33
- def svgmap_resolve_eref(eref, isodoc, _docxml, ids)
41
+ def svgmap_resolve_eref(eref, isodoc, _docxml, ids, presxml)
34
42
  href = isodoc.eref_target(eref) or return
35
43
  href = href[:link]
36
44
  href == "##{eref['bibitemid']}" ||
37
45
  (href =~ /^#/ && !ids[href.sub(/^#/, "")]) and return
38
46
  eref["target"] = href.strip
39
- eref.name = "link"
47
+ eref.name = presxml ? "fmt-link" : "link"
40
48
  eref.elements&.remove
41
49
  end
42
50
  end
@@ -58,8 +58,9 @@ module Metanorma
58
58
  ::Metanorma::Collection::Util::key(docid_prefix(docid))
59
59
  end
60
60
 
61
- def collect_erefs(docxml)
62
- docxml.xpath(ns("//eref"))
61
+ def collect_erefs(docxml, presxml)
62
+ tag = presxml ? "fmt-eref" : "eref"
63
+ docxml.xpath(ns("//#{tag}"))
63
64
  .each_with_object({ citeas: {}, bibitemid: {} }) do |i, m|
64
65
  m[:citeas][i["citeas"]] = true
65
66
  m[:bibitemid][i["bibitemid"]] = true
@@ -195,7 +196,7 @@ module Metanorma
195
196
  end.doc.root.to_html
196
197
  end
197
198
 
198
- def eref2link(docxml)
199
+ def eref2link(docxml, presxml)
199
200
  isodoc = IsoDoc::PresentationXMLConvert.new({})
200
201
  isodoc.bibitem_lookup(docxml)
201
202
  isodoc.eref2link(docxml)
@@ -39,7 +39,8 @@ module Metanorma
39
39
  empty = empty_doc(xml)
40
40
  empty1 = empty_attachments(empty)
41
41
  @mutex = Mutex.new
42
- @pool = Concurrent::FixedThreadPool.new(4)
42
+ #@pool = Concurrent::FixedThreadPool.new(4)
43
+ @pool = Concurrent::FixedThreadPool.new(1)
43
44
  sectionsplit1(xml, empty, empty1, 0)
44
45
  end
45
46
 
@@ -85,6 +86,7 @@ module Metanorma
85
86
  xml, type = sectionsplit_preprocess_semxml(file, filename)
86
87
  flags = { format: :asciidoc, extension_keys: [:presentation],
87
88
  type: type }.merge(@compile_opts)
89
+ #require "debug"; binding.b
88
90
  Compile.new.compile(xml, flags)
89
91
  f = File.open(xml.sub(/\.xml$/, ".presentation.xml"), encoding: "utf-8")
90
92
  r = Nokogiri::XML(f, &:huge)
@@ -95,7 +97,8 @@ module Metanorma
95
97
 
96
98
  def sectionsplit_preprocess_semxml(file, filename)
97
99
  xml = Nokogiri::XML(file, &:huge)
98
- type = xml.root.name.sub("-standard", "").to_sym
100
+ type = xml.root["flavor"]
101
+ type ||= xml.root.name.sub("-standard", "").to_sym
99
102
  sectionsplit_update_xrefs(xml)
100
103
  xml1 = sectionsplit_write_semxml(filename, xml)
101
104
  @tmp_filename = xml1
@@ -106,6 +109,7 @@ module Metanorma
106
109
  if c = @fileslookup&.parent
107
110
  n = c.nested
108
111
  c.nested = true # so unresolved erefs are not deleted
112
+ #require "debug"; binding.b
109
113
  c.update_xrefs(xml, @ident, {})
110
114
  c.nested = n
111
115
  xml.xpath("//xmlns:svgmap").each { |x| x.name = "svgmap1" }
@@ -160,10 +164,11 @@ module Metanorma
160
164
 
161
165
  def create_sectionfile(xml, out, file, chunks, parentnode)
162
166
  ins = out.at(ns("//metanorma-extension")) || out.at(ns("//bibdata"))
167
+ #require "debug"; binding.b
163
168
  sectionfile_insert(ins, chunks, parentnode)
164
169
  Metanorma::Collection::XrefProcess::xref_process(out, xml, @key,
165
- @ident, @isodoc)
166
- truncate_semxml(out, chunks)
170
+ @ident, @isodoc, true)
171
+ #truncate_semxml(out, chunks)
167
172
  outname = "#{file}.xml"
168
173
  File.open(File.join(@splitdir, outname), "w:UTF-8") do |f|
169
174
  f.write(out)
@@ -171,6 +176,7 @@ module Metanorma
171
176
  outname
172
177
  end
173
178
 
179
+ # KILL
174
180
  def semantic_xml_ids_gather(out)
175
181
  out.at(ns("//semantic__bibdata")) or return
176
182
  SPLITSECTIONS.each_with_object({}) do |s, m|
@@ -181,12 +187,14 @@ module Metanorma
181
187
  end
182
188
  end
183
189
 
190
+ # KILL
184
191
  def semxml_presxml_nodes_match(nodes, chunks)
185
192
  chunks.each do |x|
186
193
  nodes[x["id"]] and nodes.delete(x["id"])
187
194
  end
188
195
  end
189
196
 
197
+ # KILL
190
198
  def truncate_semxml(out, chunks)
191
199
  nodes = semantic_xml_ids_gather(out) or return
192
200
  semxml_presxml_nodes_match(nodes, chunks)
@@ -14,17 +14,19 @@ module Metanorma
14
14
  end
15
15
  end
16
16
 
17
- def gather_bibitemids(xml)
17
+ def gather_bibitemids(xml, presxml)
18
18
  xml.xpath("//*[@bibitemid]").each_with_object({}) do |e, m|
19
- /^semantic__/.match?(e.name) and next
19
+ #/^semantic__/.match?(e.name) and next
20
+ presxml && %w(xref eref link).include?(e.name) and next
20
21
  m[e["bibitemid"]] ||= []
21
22
  m[e["bibitemid"]] << e
22
23
  end
23
24
  end
24
25
 
25
- def gather_citeases(xml)
26
+ def gather_citeases(xml, presxml)
26
27
  xml.xpath("//*[@citeas]").each_with_object({}) do |e, m|
27
- /^semantic__/.match?(e.name) and next
28
+ #/^semantic__/.match?(e.name) and next
29
+ presxml && %w(xref eref link).include?(e.name) and next
28
30
  k = key(e["citeas"])
29
31
  m[k] ||= []
30
32
  m[k] << e
@@ -5,12 +5,14 @@ module Metanorma
5
5
  # xml.root["type"] = key # to force recognition of internal refs
6
6
  # bookmarks etc as new id elements introduced in Presentation XML:
7
7
  # add doc suffix
8
+ # Run on Semantic XML
8
9
  def xref_preprocess(xml, isodoc)
9
10
  @isodoc = isodoc
10
11
  key = (0...8).map { rand(65..90).chr }.join # random string
11
12
  xml.root["type"] = key
12
13
  Metanorma::Utils::anchor_attributes
13
14
  .each do |(tag_name, attr_name)|
15
+ #tag_name == "xref" and tag_name = "fmt-xref"
14
16
  ::Metanorma::Collection::Util::add_suffix_to_attrs(
15
17
  xml, xml.root["document_suffix"], tag_name, attr_name, isodoc
16
18
  )
@@ -22,21 +24,21 @@ module Metanorma
22
24
  @isodoc.ns(xpath)
23
25
  end
24
26
 
25
- def xref_process(section, xml, key, ident, isodoc)
27
+ def xref_process(section, xml, key, ident, isodoc, presxml)
26
28
  @isodoc ||= isodoc
27
- svg_preprocess(section, Metanorma::Utils::to_ncname(ident))
28
- refs = eref_to_internal_eref(section, xml, key)
29
- refs += xref_to_internal_eref(section, xml, key)
29
+ svg_preprocess(section, Metanorma::Utils::to_ncname(ident), presxml)
30
+ refs = eref_to_internal_eref(section, xml, key, presxml)
31
+ refs += xref_to_internal_eref(section, xml, key, presxml)
30
32
  ins = new_hidden_ref(section)
31
33
  copied_refs = copy_repo_items_biblio(ins, section, xml)
32
34
  insert_indirect_biblio(ins, refs - copied_refs, key, xml)
33
35
  end
34
36
 
35
- def svg_preprocess(xml, doc_suffix)
37
+ def svg_preprocess(xml, doc_suffix, presxml)
36
38
  suffix = doc_suffix.nil? || doc_suffix.blank? ? "" : "_#{doc_suffix}"
37
39
  xml.xpath("//m:svg", "m" => "http://www.w3.org/2000/svg").each do |s|
38
40
  m = svgmap_wrap(s)
39
- svg_xrefs(s, m, suffix)
41
+ svg_xrefs(s, m, suffix, presxml)
40
42
  end
41
43
  xml
42
44
  end
@@ -48,12 +50,13 @@ module Metanorma
48
50
  svg.at("./ancestor::xmlns:svgmap")
49
51
  end
50
52
 
51
- def svg_xrefs(svg, svgmap, suffix)
53
+ def svg_xrefs(svg, svgmap, suffix, presxml)
54
+ tag = presxml ? "fmt-xref" : "xref"
52
55
  svg.xpath(".//m:a", "m" => "http://www.w3.org/2000/svg").each do |a|
53
56
  /^#/.match? a["href"] or next
54
57
  a["href"] = a["href"].sub(/^#/, "")
55
58
  svgmap << "<target href='#{a['href']}'>" \
56
- "<xref target='#{a['href']}#{suffix}'/></target>"
59
+ "<#{tag} target='#{a['href']}#{suffix}'/></target>"
57
60
  end
58
61
  end
59
62
 
@@ -65,15 +68,16 @@ module Metanorma
65
68
  "#{anchor}</referenceFrom></locality></localityStack>"
66
69
  end
67
70
 
68
- def xref_to_internal_eref(section, xml, key)
71
+ def xref_to_internal_eref(section, xml, key, presxml)
69
72
  key or return [] # no sectionsplit, no playing with xrefs
70
73
  bibitems, indirect = xref_to_internal_eref_prep(section, xml)
71
- section.xpath(ns("//xref")).each_with_object({}) do |x, m|
74
+ tag = presxml ? "fmt-xref" : "xref"
75
+ section.xpath(ns("//#{tag}")).each_with_object({}) do |x, m|
72
76
  xref_prefix_key(x, key, indirect)
73
77
  x["bibitemid"] = x["target"]
74
78
  m[x["bibitemid"]] = true
75
79
  xref_to_internal_eref_anchor(x, key, bibitems,
76
- xml.root["document_suffix"])
80
+ xml.root["document_suffix"], presxml)
77
81
  end.keys
78
82
  end
79
83
 
@@ -84,7 +88,7 @@ module Metanorma
84
88
  [bibitems, indirect_bibitems]
85
89
  end
86
90
 
87
- def xref_to_internal_eref_anchor(xref, key, bibitems, document_suffix)
91
+ def xref_to_internal_eref_anchor(xref, key, bibitems, document_suffix, presxml)
88
92
  t = xref["target"]
89
93
  if d = bibitems[t]&.at(ns("./docidentifier[@type = 'repository']"))
90
94
  m = %r{^([^/]+)}.match(d.text) and
@@ -93,7 +97,7 @@ module Metanorma
93
97
  key and t.sub!(%r{^#{key}_}, "")
94
98
  make_anchor(xref, t.sub(%r(_#{document_suffix}$), ""))
95
99
  xref.delete("target")
96
- xref.name = "eref"
100
+ xref.name = presxml ? "fmt-eref" : "eref"
97
101
  end
98
102
 
99
103
  def xref_prefix_key(xref, key, indirect)
@@ -114,32 +118,32 @@ module Metanorma
114
118
  url&.text
115
119
  end
116
120
 
117
- def eref_to_internal_eref(section, xml, key)
121
+ def eref_to_internal_eref(section, xml, key, presxml)
118
122
  bibitems, indirect, bibids, lang =
119
- eref_to_internal_eref_prep(section, xml)
120
- eref_to_internal_eref_select(section, xml, bibitems)
123
+ eref_to_internal_eref_prep(section, xml, presxml)
124
+ eref_to_internal_eref_select(section, xml, bibitems, presxml)
121
125
  .each_with_object([]) do |x, m|
122
126
  url = select_citation_uri(bibitems[x], lang)
123
127
  bibids[x]&.each do |e|
124
128
  e.at(ns("./localityStack | ./locality")) and next
125
- id = eref_to_internal_eref1(e, key, url, indirect) and m << id
129
+ id = eref_to_internal_eref1(e, key, url, indirect, presxml) and m << id
126
130
  end
127
131
  end
128
132
  end
129
133
 
130
- def eref_to_internal_eref_prep(section, xml)
134
+ def eref_to_internal_eref_prep(section, xml, presxml)
131
135
  bibitems = ::Metanorma::Collection::Util::gather_bibitems(xml)
132
136
  .delete_if { |_, v| internal_bib?(v) }
133
137
  indirect = ::Metanorma::Collection::Util::gather_bibitems(xml)
134
138
  .select { |_, v| indirect_bib?(v) }
135
- bibitemids = ::Metanorma::Collection::Util::gather_bibitemids(section)
139
+ bibitemids = ::Metanorma::Collection::Util::gather_bibitemids(section, presxml)
136
140
  lang = xml.at(ns("//bibdata/language"))&.text || "en"
137
141
  [bibitems, indirect, bibitemids, lang]
138
142
  end
139
143
 
140
- def eref_to_internal_eref1(elem, key, url, indirect)
144
+ def eref_to_internal_eref1(elem, key, url, indirect, presxml)
141
145
  if url
142
- elem.name = "link"
146
+ elem.name = presxml ? "fmt-link" : "link"
143
147
  elem["target"] = url
144
148
  nil
145
149
  elsif !indirect[elem["bibitemid"]]
@@ -162,8 +166,8 @@ module Metanorma
162
166
  elem["bibitemid"]
163
167
  end
164
168
 
165
- def eref_to_internal_eref_select(section, _xml, bibitems)
166
- refs = ::Metanorma::Collection::Util::gather_bibitemids(section).keys
169
+ def eref_to_internal_eref_select(section, _xml, bibitems, presxml)
170
+ refs = ::Metanorma::Collection::Util::gather_bibitemids(section, presxml).keys
167
171
  refs.uniq.reject do |x|
168
172
  b = bibitems[x] and (indirect_bib?(b) || internal_bib?(b))
169
173
  end
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.0.11".freeze
2
+ VERSION = "2.1.2".freeze
3
3
  end
data/metanorma.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency "concurrent-ruby"
28
28
  spec.add_runtime_dependency "fontist", ">= 1.14.3"
29
29
  spec.add_runtime_dependency "htmlentities"
30
- spec.add_runtime_dependency "isodoc", ">= 2.12.2"
30
+ spec.add_runtime_dependency "isodoc", ">= 3.0.0"
31
31
  spec.add_runtime_dependency "mn2pdf", "~> 2"
32
32
  spec.add_runtime_dependency "nokogiri"
33
33
 
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.0.11
4
+ version: 2.1.2
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-01-20 00:00:00.000000000 Z
11
+ date: 2025-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 2.12.2
75
+ version: 3.0.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 2.12.2
82
+ version: 3.0.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: mn2pdf
85
85
  requirement: !ruby/object:Gem::Requirement