metanorma 2.5.16 → 2.5.18
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 +4 -4
- data/Gemfile +4 -4
- data/Gemfile.devel +6 -9
- data/lib/metanorma/collection/renderer/svg.rb +116 -13
- data/lib/metanorma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed6ff0475b37b107b11392c1f9138994c87ce6d6c7aeb96fdbdea87163c845a6
|
|
4
|
+
data.tar.gz: 02daf01867340c397af44cc50579f6aa25368052b68398994fa405d76619aad0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 26a6ab25936320630c53f7df4b8dc9c39352f5dc77f5f72b9e0d12b01c459f5cbdcd06fea0298b2387f01700067bba3a2468cd1f2dad308bf53efffb0302a463
|
|
7
|
+
data.tar.gz: e90b384b30d236a229acf8748089cd242860ea07884d049689722581cecc012645092efa7df23184e07759eb6c7911685ee457de8d1743973a63bf053f5b0e08
|
data/Gemfile
CHANGED
|
@@ -10,14 +10,14 @@ gem "relaton", "~> 3.0"
|
|
|
10
10
|
gem "metanorma-core", ">= 0.2.5"
|
|
11
11
|
|
|
12
12
|
# taste stack the compile specs exercise: the oiml taste registers the
|
|
13
|
-
# flavor and lazily requires metanorma-oiml (OIML STS transformers
|
|
14
|
-
#
|
|
13
|
+
# flavor and lazily requires metanorma-oiml (OIML STS transformers);
|
|
14
|
+
# mko carries the model-side export entry.
|
|
15
15
|
# Lives here, not in Gemfile.devel: consumer workflows may rewrite the
|
|
16
16
|
# devel overlay (fontist CI appends its path pin to it), and the repo's
|
|
17
17
|
# own compile specs must not depend on its survival.
|
|
18
18
|
gem "metanorma-taste", "~> 1.1"
|
|
19
|
-
gem "metanorma-oiml",
|
|
20
|
-
gem "metanorma-mko",
|
|
19
|
+
gem "metanorma-oiml", "~> 0.1"
|
|
20
|
+
gem "metanorma-mko", "~> 1.1"
|
|
21
21
|
|
|
22
22
|
begin
|
|
23
23
|
eval_gemfile("Gemfile.devel")
|
data/Gemfile.devel
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# Local development pins (eval'd by Gemfile; not committed workflow state)
|
|
2
|
-
gem "metanorma-document",
|
|
3
|
-
gem "metanorma-standoc",
|
|
4
|
-
gem "metanorma-iso",
|
|
5
|
-
gem "isodoc",
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# main relocated its render files
|
|
9
|
-
gem "metanorma-iho", github: "metanorma/metanorma-iho", branch: "main"
|
|
10
|
-
gem "pubid", "~> 2.0.0.pre.alpha"
|
|
2
|
+
gem "metanorma-document", "~> 0.5"
|
|
3
|
+
gem "metanorma-standoc", "~> 3.5"
|
|
4
|
+
gem "metanorma-iso", "~> 3.5"
|
|
5
|
+
gem "isodoc", "~> 3.7"
|
|
6
|
+
gem "metanorma-iho", "~> 1.4"
|
|
7
|
+
gem "pubid", "~> 2.0"
|
|
11
8
|
# The 1.9.356/0.5.13x pin pair worked around the leptris#1733 to_xml
|
|
12
9
|
# regression; retired — moxml rides the 0.6 line (0.5 series gets no
|
|
13
10
|
# fixes; 0.6.0 removed the Opal surface, lutaml/moxml#516), which
|
|
@@ -4,6 +4,24 @@ module Metanorma
|
|
|
4
4
|
SVG_NS = "http://www.w3.org/2000/svg".freeze
|
|
5
5
|
XLINK_NS = "http://www.w3.org/1999/xlink".freeze
|
|
6
6
|
|
|
7
|
+
class << self
|
|
8
|
+
# Reference-type svgmap targets (eref[@bibitemid]) resolve to the
|
|
9
|
+
# reference list. Where a flavor's references are ALSO declared as
|
|
10
|
+
# page anchors, the flavor registers a resolver mapping its
|
|
11
|
+
# reference identity to an anchor record; the registry is empty in
|
|
12
|
+
# core, which carries no domain knowledge. A resolver receives
|
|
13
|
+
# (reference_name, lookup) and returns an anchor record
|
|
14
|
+
# ({ key:, id:, url: }) or nil; lookup maps a plain anchor base to
|
|
15
|
+
# a record, edition-suffix chains included.
|
|
16
|
+
def reference_anchor_resolvers
|
|
17
|
+
@reference_anchor_resolvers ||= []
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def register_reference_anchor_resolver(&resolver)
|
|
21
|
+
reference_anchor_resolvers << resolver
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
7
25
|
# Converts SVG images to data URIs for inline embedding
|
|
8
26
|
def svg_datauri(docxml, docid)
|
|
9
27
|
rel = @files.get(docid, :rel_path)
|
|
@@ -31,7 +49,7 @@ module Metanorma
|
|
|
31
49
|
ids, docxml, isodoc, tag = svgmap_resolve_prep(docxml, docid, presxml)
|
|
32
50
|
|
|
33
51
|
# Stage 1: Resolve EREF references to their targets
|
|
34
|
-
resolve_svgmap_erefs(docxml, tag, isodoc, ids, presxml)
|
|
52
|
+
resolve_svgmap_erefs(docxml, tag, isodoc, ids, presxml, docid)
|
|
35
53
|
|
|
36
54
|
# Stage 1b: Re-key the svgmap xref targets that a reinflated render
|
|
37
55
|
# carries from the staging build: they name anchors in the compile-
|
|
@@ -82,9 +100,9 @@ module Metanorma
|
|
|
82
100
|
private
|
|
83
101
|
|
|
84
102
|
# Resolves EREF elements within svgmap to their actual link targets
|
|
85
|
-
def resolve_svgmap_erefs(docxml, tag, isodoc, ids, presxml)
|
|
103
|
+
def resolve_svgmap_erefs(docxml, tag, isodoc, ids, presxml, docid)
|
|
86
104
|
docxml.xpath(ns("//svgmap//#{tag}")).each do |e|
|
|
87
|
-
svgmap_resolve_eref(e, isodoc, docxml, ids, presxml)
|
|
105
|
+
svgmap_resolve_eref(e, isodoc, docxml, ids, presxml, docid)
|
|
88
106
|
end
|
|
89
107
|
end
|
|
90
108
|
|
|
@@ -142,16 +160,35 @@ module Metanorma
|
|
|
142
160
|
end
|
|
143
161
|
|
|
144
162
|
# Resolves a single EREF element to its target link
|
|
145
|
-
def svgmap_resolve_eref(eref, isodoc, _docxml, ids, presxml)
|
|
163
|
+
def svgmap_resolve_eref(eref, isodoc, _docxml, ids, presxml, docid)
|
|
146
164
|
href = isodoc.eref_target(eref) or return
|
|
147
165
|
href = href[:link]
|
|
148
166
|
href == "##{eref['bibitemid']}" ||
|
|
149
167
|
(href =~ /^#/ && !ids[href.sub(/^#/, "")]) and return
|
|
168
|
+
href = remap_cross_member_hotspot(href, docid)
|
|
150
169
|
eref["target"] = href.strip
|
|
151
170
|
eref.name = presxml ? "fmt-link" : "link"
|
|
152
171
|
eref.elements&.remove
|
|
153
172
|
end
|
|
154
173
|
|
|
174
|
+
# A cross-member svgmap target composes its anchor as authored
|
|
175
|
+
# (<hotspot>_<doc-stamp>), while the target page's SVG ids carry
|
|
176
|
+
# Vectory's disambiguation index (<hotspot>_<counter>) - the two
|
|
177
|
+
# conventions disagree exactly when the members render separately
|
|
178
|
+
# under staging (iso-10303 run 42346461599: 15 fragments broken).
|
|
179
|
+
# Re-key the anchor through the hotspot anchor index: exact, then the
|
|
180
|
+
# anchor with a known member-suffix stripped. Only same-file
|
|
181
|
+
# re-keys are taken; anything else is left untouched.
|
|
182
|
+
def remap_cross_member_hotspot(href, docid)
|
|
183
|
+
href =~ /\A([^#]+\.html)#(.+)\z/ or return href
|
|
184
|
+
file, anchor = Regexp.last_match(1), Regexp.last_match(2)
|
|
185
|
+
rec = hotspot_anchor_index[anchor] ||
|
|
186
|
+
hotspot_anchor_index[hotspot_anchor_base(anchor, docid)] or
|
|
187
|
+
return href
|
|
188
|
+
target = hotspot_target_href(rec, docid) or return href
|
|
189
|
+
target.start_with?("#{file}#") ? target : href
|
|
190
|
+
end
|
|
191
|
+
|
|
155
192
|
# Re-key svgmap xref targets whose anchor lives outside the current
|
|
156
193
|
# section page. The svg_xrefs pass composes these targets as
|
|
157
194
|
# +<xref target='anchor_suffix'/>+ from the SVG hotspot hrefs, naming
|
|
@@ -170,6 +207,22 @@ module Metanorma
|
|
|
170
207
|
x.name = "link"
|
|
171
208
|
x["target"] = href
|
|
172
209
|
end
|
|
210
|
+
# Reference-type targets (eref[@bibitemid]) resolve to the reference
|
|
211
|
+
# list. Where a domain's references are ALSO declared as page
|
|
212
|
+
# anchors, that domain registers a resolver mapping the reference
|
|
213
|
+
# identity to an anchor record; core registers none and carries no
|
|
214
|
+
# domain knowledge. Resolvers receive (reference_name, lookup),
|
|
215
|
+
# where lookup maps a plain anchor base to a record.
|
|
216
|
+
lookup = ->(base) { hotspot_prefix_lookup(idx, base) }
|
|
217
|
+
docxml.xpath(ns("//svgmap/target/eref[@bibitemid]")).each do |e|
|
|
218
|
+
rec = self.class.reference_anchor_resolvers.lazy.map do |resolver|
|
|
219
|
+
resolver.call(e["bibitemid"], lookup)
|
|
220
|
+
end.find(&:itself) or next
|
|
221
|
+
href = hotspot_target_href(rec, docid) or next
|
|
222
|
+
e.name = "link"
|
|
223
|
+
e["target"] = href
|
|
224
|
+
e.attribute_nodes.each { |at| at.remove unless at.name == "target" }
|
|
225
|
+
end
|
|
173
226
|
end
|
|
174
227
|
|
|
175
228
|
# Rewrites the fragment hrefs of SVG hotspot anchors that do not
|
|
@@ -190,11 +243,31 @@ module Metanorma
|
|
|
190
243
|
split = hotspot_split_href(a[attr])
|
|
191
244
|
next unless split
|
|
192
245
|
page, frag = split
|
|
193
|
-
|
|
246
|
+
if page.nil? && page_ids.key?(frag)
|
|
247
|
+
# The id exists on this page, but Vectory left the href as a
|
|
248
|
+
# bare relative name (no #): re-point it as the in-page anchor.
|
|
249
|
+
a[attr] = "##{frag}" unless a[attr].start_with?("#")
|
|
250
|
+
next
|
|
251
|
+
end
|
|
194
252
|
base = hotspot_anchor_base(frag, docid)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
253
|
+
# An SVG element id in this document: anchor the hotspot in-page.
|
|
254
|
+
in_page = if svg_ids.key?(frag)
|
|
255
|
+
frag
|
|
256
|
+
else
|
|
257
|
+
svg_ids.keys.find { |i| i.start_with?("#{base}_") }
|
|
258
|
+
end
|
|
259
|
+
if in_page
|
|
260
|
+
a[attr] = "##{in_page}"
|
|
261
|
+
next
|
|
262
|
+
end
|
|
263
|
+
rec = idx[frag] || idx[base] ||
|
|
264
|
+
hotspot_prefix_lookup(idx, base)
|
|
265
|
+
unless rec
|
|
266
|
+
# Unresolvable bare name: a dead link (relative file or
|
|
267
|
+
# dangling fragment) is worse than no link; drop the href.
|
|
268
|
+
a.remove_attribute(attr)
|
|
269
|
+
next
|
|
270
|
+
end
|
|
198
271
|
href = hotspot_target_href(rec, docid) or next
|
|
199
272
|
href = "#{page}#{href}" if page && rec[:key] == docid
|
|
200
273
|
a[attr] = href unless href == a[attr]
|
|
@@ -283,16 +356,30 @@ module Metanorma
|
|
|
283
356
|
else
|
|
284
357
|
id
|
|
285
358
|
end
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
359
|
+
register_hotspot_base(idx, base, key: key, id: final, url: url)
|
|
360
|
+
# SVG ids additionally carry Vectory's disambiguation index
|
|
361
|
+
# (<orig>_<counter>): the stored id is the assigned form, while
|
|
362
|
+
# cross-member svgmap links compose the anchor from the authored
|
|
363
|
+
# original. Register the original as a second base candidate;
|
|
364
|
+
# the ambiguity guard still nils true collisions.
|
|
365
|
+
stripped = base.sub(/_\d+\z/, "")
|
|
366
|
+
register_hotspot_base(idx, stripped, key: key, id: final,
|
|
367
|
+
url: url) if stripped != base
|
|
291
368
|
end
|
|
292
369
|
end
|
|
293
370
|
idx
|
|
294
371
|
end
|
|
295
372
|
|
|
373
|
+
def register_hotspot_base(idx, base, record)
|
|
374
|
+
return if base.empty?
|
|
375
|
+
|
|
376
|
+
if !idx.key?(base)
|
|
377
|
+
idx[base] = record
|
|
378
|
+
elsif idx[base] && idx[base][:id] != record[:id]
|
|
379
|
+
idx[base] = nil
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
|
|
296
383
|
# The member page's URL relative to the page being rendered; the index
|
|
297
384
|
# stores it collection-root-relative.
|
|
298
385
|
def hotspot_relative_url(url, docid)
|
|
@@ -309,6 +396,22 @@ module Metanorma
|
|
|
309
396
|
rec[:url] or return nil
|
|
310
397
|
"#{hotspot_relative_url(rec[:url], docid)}##{rec[:id]}"
|
|
311
398
|
end
|
|
399
|
+
|
|
400
|
+
# Exact base first, then a unique prefix match: a declaration id
|
|
401
|
+
# carries the owning member's edition suffix chain behind the plain
|
|
402
|
+
# name (geometry_schema.cartesian_point_ISO_10303-42_2025_...), so
|
|
403
|
+
# the plain name resolves by prefix. Multiple equal-length matches
|
|
404
|
+
# are ambiguous and refuse, as do differing ids at the same key.
|
|
405
|
+
def hotspot_prefix_lookup(idx, prefix)
|
|
406
|
+
return idx[prefix] if idx[prefix]
|
|
407
|
+
|
|
408
|
+
candidates = idx.select { |k, r| r && k.start_with?("#{prefix}_") }
|
|
409
|
+
return nil if candidates.empty?
|
|
410
|
+
|
|
411
|
+
shortest = candidates.min_by { |k, _| k.length }
|
|
412
|
+
ties = candidates.count { |k, _| k.length == shortest[0].length }
|
|
413
|
+
ties == 1 ? shortest[1] : nil
|
|
414
|
+
end
|
|
312
415
|
end
|
|
313
416
|
end
|
|
314
417
|
end
|
data/lib/metanorma/version.rb
CHANGED
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.
|
|
4
|
+
version: 2.5.18
|
|
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-
|
|
11
|
+
date: 2026-11-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|