metanorma 2.5.14 → 2.5.16

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: cf7e165fbc2cd9abb285653e89a551948e734eb0559ec7604a5aca0a95dd5b9a
4
- data.tar.gz: ec1328b3249691d12013228754fb63bedb4e0af0e96c0632012a0d392b46b639
3
+ metadata.gz: 9677e770c8876f2e5a74e3f8acdc53d4882ec3e51cb3b997c5946a927adf994f
4
+ data.tar.gz: 1553466c032a992f29cf62f4893aa9e4897a0221180e29e5cb3604a77f9bd74b
5
5
  SHA512:
6
- metadata.gz: 2ce1de2751cc2a73b7fcf2f02669aa777fa9f12c735091f671db83386b74ea05c20feba9f4cec9e684fa5523689562ac5acdf315b70494dbf99d5d15e5659471
7
- data.tar.gz: f8d03526b7e4253d50e8fb5c04b3d3758b07d8fbd2fb45e38753b66d7fefde214be5726cf082de910ef8502628c105a08916a2a36a889032477a1b0229f07629
6
+ metadata.gz: 6c9aa9f655bc1229da61f2ce82894a17fbca9d1be9d2f643a4c8c19a669d4bc93389ca7671d14c2df813590391ce763f840ab6bbb8166349a3051790e4b70188
7
+ data.tar.gz: 7fa9f94228a0ccfa02bc9ba65d11e7a543581e0ae889449375ff99d82cb5d9543e419f02cd780f2e9b4553040cc6eb3df91abb2e621876ecc0247eb52956b4e1
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}" }
6
6
 
7
7
  gemspec
8
8
 
9
+ gem "relaton", "~> 3.0"
9
10
  gem "metanorma-core", ">= 0.2.5"
10
11
 
11
12
  # taste stack the compile specs exercise: the oiml taste registers the
data/Gemfile.devel CHANGED
@@ -13,19 +13,12 @@ gem "pubid", "~> 2.0.0.pre.alpha"
13
13
  # fixes; 0.6.0 removed the Opal surface, lutaml/moxml#516), which
14
14
  # floors leptris >= 1.9.386 at load.
15
15
  gem "leptris", "~> 1.9"
16
- gem "relaton-cli", "~> 3.0.0.pre.alpha"
17
16
  gem "glossarist", "~> 2.13"
18
17
  gem "lutaml-model", "~> 0.8.107"
19
18
  gem "metanorma-plugin-glossarist", "~> 0.5"
20
19
  gem "moxml", "~> 0.6.0"
21
20
 
22
- # Bridge: pubid 2.0.1 (and git main, until the PARG edition-2 migration
23
- # lands) bakes grammars with the parsanol `mode` header alias, which
24
- # parsanol 1.3.113+ removed; pubid main's own floor (>= 1.3.114) admits
25
- # the breaking 1.3.120, so collection specs fail with 13 rendering
26
- # regressions. 1.3.114 is pubid's own floor and the last alias-accepting
27
- # compiler. Drop this pin when pubid ships edition-2 artifacts.
28
- gem "parsanol", "1.3.114"
21
+ gem "parsanol", "~> 1.3.129" # relaton 3.1 floor; pubid edition-2 grammar era
29
22
 
30
23
  # Bridge: svg_conform 0.2.5 was pushed with a compact-index checksum
31
24
  # mismatch (Bundler::APIResponseMismatchError on every download); pin
@@ -1,4 +1,6 @@
1
- require "relaton-cli"
1
+ require "relaton"
2
+ require "relaton/bib"
3
+ require "relaton/cli"
2
4
  require "metanorma-utils"
3
5
  require_relative "util/util"
4
6
  require_relative "util/disambig_files"
@@ -1,4 +1,6 @@
1
- require "relaton-cli"
1
+ require "relaton"
2
+ require "relaton/bib"
3
+ require "relaton/cli"
2
4
 
3
5
  module Metanorma
4
6
  class Collection
@@ -46,6 +46,12 @@ module Metanorma
46
46
  # ids untouched. (@nested is the pre-split sectionsplit pass;
47
47
  # the render loop's own pass over a sectionsplit parent is
48
48
  # discarded, so it needs no suffix handling.)
49
+ #
50
+ # The svg hotspot hrefs inside SVGs are not ids, so the swap does
51
+ # not cover them; capture the stored suffix here so the svgmap
52
+ # stages (svg.rb) can strip it from those hrefs too.
53
+ s = xml.root["document_suffix"]
54
+ @svgmap_stored_suffix = s && !s.empty? ? s : nil
49
55
  @files.swap_document_suffix(docid, xml)
50
56
  end
51
57
  # post: every @id/@anchor namespaced with this doc's NCName suffix, so
@@ -61,7 +67,20 @@ module Metanorma
61
67
  # post: references containers with only hidden bibitems flagged hidden.
62
68
  sso and eref2link(xml, sso)
63
69
  # svgmap_resolve hands back the tree Vectory rebuilt; keep it.
64
- xml = svgmap_resolve(xml, docid, sso) unless @nested || @reinflate
70
+ #
71
+ # Skipped only under @nested (the split sections run it in their own
72
+ # render). It runs on EVERY other pass -- staging (which stores the
73
+ # Vectory-processed tree, the contract the incremental and
74
+ # anchor-agreement specs pin) and reinflate alike: skipping it under
75
+ # reinflate is metanorma#656 (42 of 43 annex pages lost their
76
+ # EXPRESS-G figures; 3,692 section-to-section fragment links dead).
77
+ # Processing an already-processed stored tree at reinflate would
78
+ # double-render extracted copies and remap hotspots onto dead semx
79
+ # companions; the svg.rb stages handle both (unresolved semx
80
+ # companions are dropped so the bare semantic target survives, and
81
+ # Stage 1b/5 re-key targets and hotspot hrefs onto the member pages
82
+ # carrying the declarations).
83
+ xml = svgmap_resolve(xml, docid, sso) unless @nested
65
84
  xml.to_xml
66
85
  end
67
86
 
@@ -1,6 +1,9 @@
1
1
  module Metanorma
2
2
  class Collection
3
3
  class Renderer
4
+ SVG_NS = "http://www.w3.org/2000/svg".freeze
5
+ XLINK_NS = "http://www.w3.org/1999/xlink".freeze
6
+
4
7
  # Converts SVG images to data URIs for inline embedding
5
8
  def svg_datauri(docxml, docid)
6
9
  rel = @files.get(docid, :rel_path)
@@ -30,8 +33,19 @@ module Metanorma
30
33
  # Stage 1: Resolve EREF references to their targets
31
34
  resolve_svgmap_erefs(docxml, tag, isodoc, ids, presxml)
32
35
 
36
+ # Stage 1b: Re-key the svgmap xref targets that a reinflated render
37
+ # carries from the staging build: they name anchors in the compile-
38
+ # time document shape, which on a sectionsplit page sit behind this
39
+ # render's suffix chain and possibly on a sibling member page.
40
+ # Targets that resolve against the collection anchor index are
41
+ # rewritten to links at the owning page, so Vectory maps the SVG
42
+ # hotspots onto working addresses. A plain build skips this stage:
43
+ # its targets are already in the form the rest of the pipeline
44
+ # expects.
45
+ @reinflate and resolve_svgmap_bare_targets(docxml, docid, ids)
46
+
33
47
  # Stage 2: Normalize prefixes (Vectory expects eref, not fmt-eref)
34
- normalize_svgmap_prefixes(docxml)
48
+ normalize_svgmap_prefixes(docxml, ids)
35
49
 
36
50
  # Stage 3: Process with Vectory
37
51
  # Pass document suffix to Vectory as id_suffix for proper SVG ID disambiguation.
@@ -44,6 +58,14 @@ module Metanorma
44
58
 
45
59
  # Stage 4: Extract processed SVG content
46
60
  extract_svgmap_content(docxml, isodoc)
61
+
62
+ # Stage 5: Re-key hotspot anchors. Vectory remaps an SVG hotspot to
63
+ # the value of its svgmap target, which names an anchor in the
64
+ # compile-time document shape. On a sectionsplit page the declaration
65
+ # carries this render's suffix chain and may live on a sibling
66
+ # section page, so the fragment needs re-pointing at the member page
67
+ # that owns it.
68
+ @reinflate and svgmap_hotspot_rekey(docxml, docid)
47
69
  docxml
48
70
  end
49
71
 
@@ -68,8 +90,8 @@ module Metanorma
68
90
 
69
91
  # Converts fmt-eref/fmt-link/fmt-xref back to eref/link/xref
70
92
  # Vectory expects non-prefixed element names for proper processing
71
- def normalize_svgmap_prefixes(docxml)
72
- svgmap_fmt_prefix_remove(docxml)
93
+ def normalize_svgmap_prefixes(docxml, ids)
94
+ svgmap_fmt_prefix_remove(docxml, ids)
73
95
  end
74
96
 
75
97
  # Extracts processed SVG content from svgmap elements
@@ -78,15 +100,38 @@ module Metanorma
78
100
  end
79
101
 
80
102
  # Converts Presentation XML fmt- prefix back to standard element names
81
- # Vectory expects eref/link/xref, not fmt-eref/fmt-link/fmt-xref
82
- def svgmap_fmt_prefix_remove(docxml)
103
+ # Vectory expects eref/link/xref, not fmt-eref/fmt-link/fmt-xref.
104
+ #
105
+ # A target carrying an unresolved fmt-xref/fmt-eref companion next to a
106
+ # resolvable bare node keeps the bare node: the companion is the
107
+ # anchor-type xref the cross-reference machinery fell back to when it
108
+ # could not resolve the reference (its target names a hidden bibitem,
109
+ # not a page anchor), and replacing the target's children with it would
110
+ # have Vectory remap the SVG hotspots to that dead anchor. Dropping the
111
+ # companion leaves the bare eref/xref as the target, so an unresolved
112
+ # svgmap keeps its wrapper (the figure renders once through its
113
+ # extracted copy) and the hotspots are left untouched.
114
+ def svgmap_fmt_prefix_remove(docxml, ids)
83
115
  docxml.xpath(ns("//svgmap/target")).each do |t|
116
+ # A target Stage 1b already resolved to a link is final.
117
+ t.at(ns("./link")) and next
84
118
  n = t.at(ns(".//fmt-link | .//fmt-xref | .//fmt-eref")) or next
119
+ if n.name != "fmt-link" && t.at(ns("./eref | ./xref")) &&
120
+ !ids&.key?(n["target"])
121
+ svgmap_drop_unresolved_companion(n)
122
+ next
123
+ end
85
124
  n.name = n.name.sub(/^fmt-/, "")
86
125
  t.children = n
87
126
  end
88
127
  end
89
128
 
129
+ # Remove the semx companion carrying +node+, leaving the target's bare
130
+ # semantic child in place.
131
+ def svgmap_drop_unresolved_companion(node)
132
+ (sm = node.at("./ancestor::xmlns:semx")) and sm.remove
133
+ end
134
+
90
135
  # Removes nested image elements within svgmap, flattening the structure
91
136
  def svg_unnest(docxml)
92
137
  docxml.xpath(ns("//svgmap//image[.//*[name() = 'image']]")).each do |i|
@@ -106,6 +151,164 @@ module Metanorma
106
151
  eref.name = presxml ? "fmt-link" : "link"
107
152
  eref.elements&.remove
108
153
  end
154
+
155
+ # Re-key svgmap xref targets whose anchor lives outside the current
156
+ # section page. The svg_xrefs pass composes these targets as
157
+ # +<xref target='anchor_suffix'/>+ from the SVG hotspot hrefs, naming
158
+ # the anchor in the compile-time document shape; on a sectionsplit page
159
+ # the declaration carries this render's suffix chain and may live on a
160
+ # sibling member page. Resolvable targets are rewritten to links at the
161
+ # owning page, so Vectory maps the SVG hotspots onto working addresses;
162
+ # unresolvable ones are left for Stage 2.
163
+ def resolve_svgmap_bare_targets(docxml, docid, ids)
164
+ idx = hotspot_anchor_index
165
+ docxml.xpath(ns("//svgmap/target/xref")).each do |x|
166
+ ids&.key?(x["target"]) and next
167
+ t = x["target"]
168
+ rec = idx[t] || idx[hotspot_anchor_base(t, docid)] or next
169
+ href = hotspot_target_href(rec, docid) or next
170
+ x.name = "link"
171
+ x["target"] = href
172
+ end
173
+ end
174
+
175
+ # Rewrites the fragment hrefs of SVG hotspot anchors that do not
176
+ # resolve on the current split-section page to the member page that
177
+ # carries the declaration, with that page's full anchor id. Both
178
+ # fragment-only (+#anchor+) and page-qualified (page.html#anchor)
179
+ # hrefs are re-keyed; bare ordinal hrefs belong to the svgmap list
180
+ # mapping and are left to the target machinery.
181
+ def svgmap_hotspot_rekey(docxml, docid)
182
+ idx = hotspot_anchor_index
183
+ page_ids = docxml.xpath("//*[@id]")
184
+ .each_with_object({}) { |e, m| m[e["id"]] = true }
185
+ svg_ids = docxml.xpath("//m:svg//@id", "m" => SVG_NS)
186
+ .each_with_object({}) { |n, m| m[n.value] = true }
187
+ docxml.xpath("//m:svg//m:a[@href] | //m:svg//m:a[@xlink:href]",
188
+ "m" => SVG_NS, "xlink" => XLINK_NS).each do |a|
189
+ attr = a.attribute("href") ? "href" : "xlink:href"
190
+ split = hotspot_split_href(a[attr])
191
+ next unless split
192
+ page, frag = split
193
+ next if page.nil? && page_ids.key?(frag)
194
+ base = hotspot_anchor_base(frag, docid)
195
+ next if svg_ids.key?(base) ||
196
+ svg_ids.any? { |i, _| i.start_with?("#{base}_") }
197
+ rec = idx[frag] || idx[base] or next
198
+ href = hotspot_target_href(rec, docid) or next
199
+ href = "#{page}#{href}" if page && rec[:key] == docid
200
+ a[attr] = href unless href == a[attr]
201
+ end
202
+ end
203
+
204
+ # Split an href into [relative page or nil, fragment]; bare values are
205
+ # treated as fragments, except ordinals, which are not anchors.
206
+ def hotspot_split_href(href)
207
+ return nil if href.nil? || href.empty? || /\A\d+\z/.match?(href)
208
+
209
+ return [nil, href] unless (m = href.match(/\A([^#]*)#(.+)\z/))
210
+
211
+ [m[1].empty? ? nil : m[1], m[2]]
212
+ end
213
+
214
+ # Reduce a fragment carrying document-suffix chains or the sectionsplit
215
+ # indirect key to its base anchor id, by iteratively stripping the
216
+ # NCName suffixes of the collection's member keys.
217
+ def hotspot_anchor_base(frag, docid)
218
+ frag = frag.to_s.sub(/\A#/, "")
219
+ if (key = @files.get(docid, :indirect_key))
220
+ frag = frag.sub(/^#{Regexp.escape(key)}_/, "")
221
+ end
222
+ suffixes = hotspot_anchor_suffixes
223
+ loop do
224
+ s = suffixes.find { |x| frag.end_with?("_#{x}") } or break
225
+ frag = frag[0...(-1 * (s.size + 1))]
226
+ end
227
+ frag
228
+ end
229
+
230
+ # NCName suffixes that link anchors in this render may carry, longest
231
+ # first: the keys of the collection's members and split outputs, which
232
+ # compose the render's suffix chains, plus the suffix the staging
233
+ # build stamped the stored documents with (captured before the
234
+ # reinflate suffix swap re-keys the ids; the SVG hotspot hrefs are not
235
+ # ids and so keep the stored flavour).
236
+ def hotspot_anchor_suffixes
237
+ @hotspot_anchor_suffixes ||= begin
238
+ keys = @files.keys
239
+ .reject { |k| @files.get(k, :attachment) }
240
+ .map { |k| Metanorma::Utils::to_ncname(k) }
241
+ keys << @svgmap_stored_suffix if @svgmap_stored_suffix
242
+ keys.uniq.sort_by(&:length).reverse
243
+ end
244
+ end
245
+
246
+ # base anchor id => { key, id, url } for every member of the
247
+ # collection; ambiguous bases (the same base resolving to different
248
+ # final ids) map to nil. Split outputs register their render-time
249
+ # suffix chain (parent suffix + split-instance key), mirroring the
250
+ # swap_document_suffix + add_document_suffix discipline; other members
251
+ # register their stored ids untouched, which is what reinflation
252
+ # renders them with.
253
+ def hotspot_anchor_index
254
+ @hotspot_anchor_index ||= build_hotspot_anchor_index
255
+ end
256
+
257
+ def build_hotspot_anchor_index
258
+ idx = {}
259
+ @files.keys.each do |key|
260
+ # Attachments carry no pages; a sectionsplit parent has no page of
261
+ # its own -- its content lives on the split outputs, whose ids are
262
+ # indexed instead.
263
+ @files.get(key, :attachment) and next
264
+ @files.get(key, :sectionsplit) and next
265
+ ids = @files.get(key, :ids) or next
266
+ pid = @files.get(key, :parentid)
267
+ url = @files.url(key, relative: true, doc: true)
268
+ ids.each_key do |id|
269
+ # The split outputs carry this render's parent suffix (the
270
+ # pre-split pass re-keys the stored ids to it); other members
271
+ # carry their identifier suffix. The base is the anchor without
272
+ # that suffix; the final id is what the render's suffix
273
+ # discipline produces on the page.
274
+ base = if pid
275
+ id.sub(/_#{Regexp.escape(Metanorma::Utils::to_ncname(pid))}\z/,
276
+ "")
277
+ else
278
+ id.sub(/_#{Regexp.escape(Metanorma::Utils::to_ncname(key))}\z/,
279
+ "")
280
+ end
281
+ final = if pid
282
+ "#{id}_#{Metanorma::Utils::to_ncname(key)}"
283
+ else
284
+ id
285
+ end
286
+ if !idx.key?(base)
287
+ idx[base] = { key: key, id: final, url: url }
288
+ elsif idx[base] && idx[base][:id] != final
289
+ idx[base] = nil
290
+ end
291
+ end
292
+ end
293
+ idx
294
+ end
295
+
296
+ # The member page's URL relative to the page being rendered; the index
297
+ # stores it collection-root-relative.
298
+ def hotspot_relative_url(url, docid)
299
+ @hotspot_rel_urls ||= {}
300
+ @hotspot_rel_urls[[url, docid]] ||= begin
301
+ cur = referencing_html_location(docid, false)
302
+ cur ? make_relative_path(cur, url) : url
303
+ end
304
+ end
305
+
306
+ # Address of the anchor record from the page being rendered.
307
+ def hotspot_target_href(rec, docid)
308
+ rec[:key] == docid and return "##{rec[:id]}"
309
+ rec[:url] or return nil
310
+ "#{hotspot_relative_url(rec[:url], docid)}##{rec[:id]}"
311
+ end
109
312
  end
110
313
  end
111
314
  end
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.5.14".freeze
2
+ VERSION = "2.5.16".freeze
3
3
  end
data/lib/metanorma.rb CHANGED
@@ -12,6 +12,12 @@ require "metanorma/collection/manifest/manifest"
12
12
  require "metanorma/collection/renderer/renderer"
13
13
  require "metanorma/collection/document/document"
14
14
  require "vectory"
15
+ # The collection renderer drives Relaton::Render directly, and isodoc's
16
+ # render wiring reaches the gem through sub-paths that do not define the
17
+ # Unrenderable marker its render_all rescue raises (the same break
18
+ # isodoc#882/#883 fixed on the isodoc side); load the full entry so the
19
+ # constant exists for every consumer of this library.
20
+ require "relaton/render"
15
21
 
16
22
  # Metanorma module
17
23
  module Metanorma
data/metanorma.gemspec CHANGED
@@ -42,5 +42,6 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency "metanorma-iho"
43
43
  spec.add_development_dependency "metanorma-iso"
44
44
 
45
- # relaton-cli is required by Metanorma::Collection
46
- spec.add_dependency "relaton-cli", "~> 3.0"end
45
+ # Metanorma::Collection uses Relaton::Cli.parse_xml, shipped in relaton >= 3.1
46
+ spec.add_dependency "relaton", "~> 3.1.1"
47
+ 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.5.14
4
+ version: 2.5.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-05 00:00:00.000000000 Z
11
+ date: 2026-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -207,19 +207,19 @@ dependencies:
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
- name: relaton-cli
210
+ name: relaton
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '3.0'
215
+ version: 3.1.1
216
216
  type: :runtime
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: '3.0'
222
+ version: 3.1.1
223
223
  description: Library to process any Metanorma standard.
224
224
  email:
225
225
  - open.source@ribose.com