metanorma 2.5.15 → 2.5.17
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.devel +1 -8
- data/lib/metanorma/collection/collection.rb +3 -1
- data/lib/metanorma/collection/document/document.rb +3 -1
- data/lib/metanorma/collection/renderer/fileparse.rb +20 -1
- data/lib/metanorma/collection/renderer/svg.rb +278 -5
- data/lib/metanorma/version.rb +1 -1
- data/lib/metanorma.rb +6 -0
- data/metanorma.gemspec +3 -2
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e74645aab84c8445fdcbdab1190af0c3e885aa315b987d9f608c6633d2453fd0
|
|
4
|
+
data.tar.gz: e71224bccf1879c5356ad8420b638d31de3bfa4f602fbed210328990965c1e2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e499614dc2d81c316a92908f5bd22e1fff19b92095ccbabff70a1411bd011e4e7fbef871a490c9ed3d17d76d3ed20ceebcf6c967b7503a6ca4a2756dfe974eeb
|
|
7
|
+
data.tar.gz: 56c95bb8a97425b3b6f3106f91fd5c92fba09383d135251fc2c4998c35f4ba88244b849b9f11a23eb08d8280699cdcb58a12cc448db91d6658b95305c3408104
|
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
|
-
|
|
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
|
|
@@ -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
|
-
|
|
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,27 @@
|
|
|
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
|
+
|
|
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
|
+
|
|
4
25
|
# Converts SVG images to data URIs for inline embedding
|
|
5
26
|
def svg_datauri(docxml, docid)
|
|
6
27
|
rel = @files.get(docid, :rel_path)
|
|
@@ -30,8 +51,19 @@ module Metanorma
|
|
|
30
51
|
# Stage 1: Resolve EREF references to their targets
|
|
31
52
|
resolve_svgmap_erefs(docxml, tag, isodoc, ids, presxml)
|
|
32
53
|
|
|
54
|
+
# Stage 1b: Re-key the svgmap xref targets that a reinflated render
|
|
55
|
+
# carries from the staging build: they name anchors in the compile-
|
|
56
|
+
# time document shape, which on a sectionsplit page sit behind this
|
|
57
|
+
# render's suffix chain and possibly on a sibling member page.
|
|
58
|
+
# Targets that resolve against the collection anchor index are
|
|
59
|
+
# rewritten to links at the owning page, so Vectory maps the SVG
|
|
60
|
+
# hotspots onto working addresses. A plain build skips this stage:
|
|
61
|
+
# its targets are already in the form the rest of the pipeline
|
|
62
|
+
# expects.
|
|
63
|
+
@reinflate and resolve_svgmap_bare_targets(docxml, docid, ids)
|
|
64
|
+
|
|
33
65
|
# Stage 2: Normalize prefixes (Vectory expects eref, not fmt-eref)
|
|
34
|
-
normalize_svgmap_prefixes(docxml)
|
|
66
|
+
normalize_svgmap_prefixes(docxml, ids)
|
|
35
67
|
|
|
36
68
|
# Stage 3: Process with Vectory
|
|
37
69
|
# Pass document suffix to Vectory as id_suffix for proper SVG ID disambiguation.
|
|
@@ -44,6 +76,14 @@ module Metanorma
|
|
|
44
76
|
|
|
45
77
|
# Stage 4: Extract processed SVG content
|
|
46
78
|
extract_svgmap_content(docxml, isodoc)
|
|
79
|
+
|
|
80
|
+
# Stage 5: Re-key hotspot anchors. Vectory remaps an SVG hotspot to
|
|
81
|
+
# the value of its svgmap target, which names an anchor in the
|
|
82
|
+
# compile-time document shape. On a sectionsplit page the declaration
|
|
83
|
+
# carries this render's suffix chain and may live on a sibling
|
|
84
|
+
# section page, so the fragment needs re-pointing at the member page
|
|
85
|
+
# that owns it.
|
|
86
|
+
@reinflate and svgmap_hotspot_rekey(docxml, docid)
|
|
47
87
|
docxml
|
|
48
88
|
end
|
|
49
89
|
|
|
@@ -68,8 +108,8 @@ module Metanorma
|
|
|
68
108
|
|
|
69
109
|
# Converts fmt-eref/fmt-link/fmt-xref back to eref/link/xref
|
|
70
110
|
# Vectory expects non-prefixed element names for proper processing
|
|
71
|
-
def normalize_svgmap_prefixes(docxml)
|
|
72
|
-
svgmap_fmt_prefix_remove(docxml)
|
|
111
|
+
def normalize_svgmap_prefixes(docxml, ids)
|
|
112
|
+
svgmap_fmt_prefix_remove(docxml, ids)
|
|
73
113
|
end
|
|
74
114
|
|
|
75
115
|
# Extracts processed SVG content from svgmap elements
|
|
@@ -78,15 +118,38 @@ module Metanorma
|
|
|
78
118
|
end
|
|
79
119
|
|
|
80
120
|
# Converts Presentation XML fmt- prefix back to standard element names
|
|
81
|
-
# Vectory expects eref/link/xref, not fmt-eref/fmt-link/fmt-xref
|
|
82
|
-
|
|
121
|
+
# Vectory expects eref/link/xref, not fmt-eref/fmt-link/fmt-xref.
|
|
122
|
+
#
|
|
123
|
+
# A target carrying an unresolved fmt-xref/fmt-eref companion next to a
|
|
124
|
+
# resolvable bare node keeps the bare node: the companion is the
|
|
125
|
+
# anchor-type xref the cross-reference machinery fell back to when it
|
|
126
|
+
# could not resolve the reference (its target names a hidden bibitem,
|
|
127
|
+
# not a page anchor), and replacing the target's children with it would
|
|
128
|
+
# have Vectory remap the SVG hotspots to that dead anchor. Dropping the
|
|
129
|
+
# companion leaves the bare eref/xref as the target, so an unresolved
|
|
130
|
+
# svgmap keeps its wrapper (the figure renders once through its
|
|
131
|
+
# extracted copy) and the hotspots are left untouched.
|
|
132
|
+
def svgmap_fmt_prefix_remove(docxml, ids)
|
|
83
133
|
docxml.xpath(ns("//svgmap/target")).each do |t|
|
|
134
|
+
# A target Stage 1b already resolved to a link is final.
|
|
135
|
+
t.at(ns("./link")) and next
|
|
84
136
|
n = t.at(ns(".//fmt-link | .//fmt-xref | .//fmt-eref")) or next
|
|
137
|
+
if n.name != "fmt-link" && t.at(ns("./eref | ./xref")) &&
|
|
138
|
+
!ids&.key?(n["target"])
|
|
139
|
+
svgmap_drop_unresolved_companion(n)
|
|
140
|
+
next
|
|
141
|
+
end
|
|
85
142
|
n.name = n.name.sub(/^fmt-/, "")
|
|
86
143
|
t.children = n
|
|
87
144
|
end
|
|
88
145
|
end
|
|
89
146
|
|
|
147
|
+
# Remove the semx companion carrying +node+, leaving the target's bare
|
|
148
|
+
# semantic child in place.
|
|
149
|
+
def svgmap_drop_unresolved_companion(node)
|
|
150
|
+
(sm = node.at("./ancestor::xmlns:semx")) and sm.remove
|
|
151
|
+
end
|
|
152
|
+
|
|
90
153
|
# Removes nested image elements within svgmap, flattening the structure
|
|
91
154
|
def svg_unnest(docxml)
|
|
92
155
|
docxml.xpath(ns("//svgmap//image[.//*[name() = 'image']]")).each do |i|
|
|
@@ -106,6 +169,216 @@ module Metanorma
|
|
|
106
169
|
eref.name = presxml ? "fmt-link" : "link"
|
|
107
170
|
eref.elements&.remove
|
|
108
171
|
end
|
|
172
|
+
|
|
173
|
+
# Re-key svgmap xref targets whose anchor lives outside the current
|
|
174
|
+
# section page. The svg_xrefs pass composes these targets as
|
|
175
|
+
# +<xref target='anchor_suffix'/>+ from the SVG hotspot hrefs, naming
|
|
176
|
+
# the anchor in the compile-time document shape; on a sectionsplit page
|
|
177
|
+
# the declaration carries this render's suffix chain and may live on a
|
|
178
|
+
# sibling member page. Resolvable targets are rewritten to links at the
|
|
179
|
+
# owning page, so Vectory maps the SVG hotspots onto working addresses;
|
|
180
|
+
# unresolvable ones are left for Stage 2.
|
|
181
|
+
def resolve_svgmap_bare_targets(docxml, docid, ids)
|
|
182
|
+
idx = hotspot_anchor_index
|
|
183
|
+
docxml.xpath(ns("//svgmap/target/xref")).each do |x|
|
|
184
|
+
ids&.key?(x["target"]) and next
|
|
185
|
+
t = x["target"]
|
|
186
|
+
rec = idx[t] || idx[hotspot_anchor_base(t, docid)] or next
|
|
187
|
+
href = hotspot_target_href(rec, docid) or next
|
|
188
|
+
x.name = "link"
|
|
189
|
+
x["target"] = href
|
|
190
|
+
end
|
|
191
|
+
# Reference-type targets (eref[@bibitemid]) resolve to the reference
|
|
192
|
+
# list. Where a domain's references are ALSO declared as page
|
|
193
|
+
# anchors, that domain registers a resolver mapping the reference
|
|
194
|
+
# identity to an anchor record; core registers none and carries no
|
|
195
|
+
# domain knowledge. Resolvers receive (reference_name, lookup),
|
|
196
|
+
# where lookup maps a plain anchor base to a record.
|
|
197
|
+
lookup = ->(base) { hotspot_prefix_lookup(idx, base) }
|
|
198
|
+
docxml.xpath(ns("//svgmap/target/eref[@bibitemid]")).each do |e|
|
|
199
|
+
rec = self.class.reference_anchor_resolvers.lazy.map do |resolver|
|
|
200
|
+
resolver.call(e["bibitemid"], lookup)
|
|
201
|
+
end.find(&:itself) or next
|
|
202
|
+
href = hotspot_target_href(rec, docid) or next
|
|
203
|
+
e.name = "link"
|
|
204
|
+
e["target"] = href
|
|
205
|
+
e.attribute_nodes.each { |at| at.remove unless at.name == "target" }
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Rewrites the fragment hrefs of SVG hotspot anchors that do not
|
|
210
|
+
# resolve on the current split-section page to the member page that
|
|
211
|
+
# carries the declaration, with that page's full anchor id. Both
|
|
212
|
+
# fragment-only (+#anchor+) and page-qualified (page.html#anchor)
|
|
213
|
+
# hrefs are re-keyed; bare ordinal hrefs belong to the svgmap list
|
|
214
|
+
# mapping and are left to the target machinery.
|
|
215
|
+
def svgmap_hotspot_rekey(docxml, docid)
|
|
216
|
+
idx = hotspot_anchor_index
|
|
217
|
+
page_ids = docxml.xpath("//*[@id]")
|
|
218
|
+
.each_with_object({}) { |e, m| m[e["id"]] = true }
|
|
219
|
+
svg_ids = docxml.xpath("//m:svg//@id", "m" => SVG_NS)
|
|
220
|
+
.each_with_object({}) { |n, m| m[n.value] = true }
|
|
221
|
+
docxml.xpath("//m:svg//m:a[@href] | //m:svg//m:a[@xlink:href]",
|
|
222
|
+
"m" => SVG_NS, "xlink" => XLINK_NS).each do |a|
|
|
223
|
+
attr = a.attribute("href") ? "href" : "xlink:href"
|
|
224
|
+
split = hotspot_split_href(a[attr])
|
|
225
|
+
next unless split
|
|
226
|
+
page, frag = split
|
|
227
|
+
if page.nil? && page_ids.key?(frag)
|
|
228
|
+
# The id exists on this page, but Vectory left the href as a
|
|
229
|
+
# bare relative name (no #): re-point it as the in-page anchor.
|
|
230
|
+
a[attr] = "##{frag}" unless a[attr].start_with?("#")
|
|
231
|
+
next
|
|
232
|
+
end
|
|
233
|
+
base = hotspot_anchor_base(frag, docid)
|
|
234
|
+
# An SVG element id in this document: anchor the hotspot in-page.
|
|
235
|
+
in_page = if svg_ids.key?(frag)
|
|
236
|
+
frag
|
|
237
|
+
else
|
|
238
|
+
svg_ids.keys.find { |i| i.start_with?("#{base}_") }
|
|
239
|
+
end
|
|
240
|
+
if in_page
|
|
241
|
+
a[attr] = "##{in_page}"
|
|
242
|
+
next
|
|
243
|
+
end
|
|
244
|
+
rec = idx[frag] || idx[base] ||
|
|
245
|
+
hotspot_prefix_lookup(idx, base)
|
|
246
|
+
unless rec
|
|
247
|
+
# Unresolvable bare name: a dead link (relative file or
|
|
248
|
+
# dangling fragment) is worse than no link; drop the href.
|
|
249
|
+
a.remove_attribute(attr)
|
|
250
|
+
next
|
|
251
|
+
end
|
|
252
|
+
href = hotspot_target_href(rec, docid) or next
|
|
253
|
+
href = "#{page}#{href}" if page && rec[:key] == docid
|
|
254
|
+
a[attr] = href unless href == a[attr]
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Split an href into [relative page or nil, fragment]; bare values are
|
|
259
|
+
# treated as fragments, except ordinals, which are not anchors.
|
|
260
|
+
def hotspot_split_href(href)
|
|
261
|
+
return nil if href.nil? || href.empty? || /\A\d+\z/.match?(href)
|
|
262
|
+
|
|
263
|
+
return [nil, href] unless (m = href.match(/\A([^#]*)#(.+)\z/))
|
|
264
|
+
|
|
265
|
+
[m[1].empty? ? nil : m[1], m[2]]
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Reduce a fragment carrying document-suffix chains or the sectionsplit
|
|
269
|
+
# indirect key to its base anchor id, by iteratively stripping the
|
|
270
|
+
# NCName suffixes of the collection's member keys.
|
|
271
|
+
def hotspot_anchor_base(frag, docid)
|
|
272
|
+
frag = frag.to_s.sub(/\A#/, "")
|
|
273
|
+
if (key = @files.get(docid, :indirect_key))
|
|
274
|
+
frag = frag.sub(/^#{Regexp.escape(key)}_/, "")
|
|
275
|
+
end
|
|
276
|
+
suffixes = hotspot_anchor_suffixes
|
|
277
|
+
loop do
|
|
278
|
+
s = suffixes.find { |x| frag.end_with?("_#{x}") } or break
|
|
279
|
+
frag = frag[0...(-1 * (s.size + 1))]
|
|
280
|
+
end
|
|
281
|
+
frag
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# NCName suffixes that link anchors in this render may carry, longest
|
|
285
|
+
# first: the keys of the collection's members and split outputs, which
|
|
286
|
+
# compose the render's suffix chains, plus the suffix the staging
|
|
287
|
+
# build stamped the stored documents with (captured before the
|
|
288
|
+
# reinflate suffix swap re-keys the ids; the SVG hotspot hrefs are not
|
|
289
|
+
# ids and so keep the stored flavour).
|
|
290
|
+
def hotspot_anchor_suffixes
|
|
291
|
+
@hotspot_anchor_suffixes ||= begin
|
|
292
|
+
keys = @files.keys
|
|
293
|
+
.reject { |k| @files.get(k, :attachment) }
|
|
294
|
+
.map { |k| Metanorma::Utils::to_ncname(k) }
|
|
295
|
+
keys << @svgmap_stored_suffix if @svgmap_stored_suffix
|
|
296
|
+
keys.uniq.sort_by(&:length).reverse
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
# base anchor id => { key, id, url } for every member of the
|
|
301
|
+
# collection; ambiguous bases (the same base resolving to different
|
|
302
|
+
# final ids) map to nil. Split outputs register their render-time
|
|
303
|
+
# suffix chain (parent suffix + split-instance key), mirroring the
|
|
304
|
+
# swap_document_suffix + add_document_suffix discipline; other members
|
|
305
|
+
# register their stored ids untouched, which is what reinflation
|
|
306
|
+
# renders them with.
|
|
307
|
+
def hotspot_anchor_index
|
|
308
|
+
@hotspot_anchor_index ||= build_hotspot_anchor_index
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def build_hotspot_anchor_index
|
|
312
|
+
idx = {}
|
|
313
|
+
@files.keys.each do |key|
|
|
314
|
+
# Attachments carry no pages; a sectionsplit parent has no page of
|
|
315
|
+
# its own -- its content lives on the split outputs, whose ids are
|
|
316
|
+
# indexed instead.
|
|
317
|
+
@files.get(key, :attachment) and next
|
|
318
|
+
@files.get(key, :sectionsplit) and next
|
|
319
|
+
ids = @files.get(key, :ids) or next
|
|
320
|
+
pid = @files.get(key, :parentid)
|
|
321
|
+
url = @files.url(key, relative: true, doc: true)
|
|
322
|
+
ids.each_key do |id|
|
|
323
|
+
# The split outputs carry this render's parent suffix (the
|
|
324
|
+
# pre-split pass re-keys the stored ids to it); other members
|
|
325
|
+
# carry their identifier suffix. The base is the anchor without
|
|
326
|
+
# that suffix; the final id is what the render's suffix
|
|
327
|
+
# discipline produces on the page.
|
|
328
|
+
base = if pid
|
|
329
|
+
id.sub(/_#{Regexp.escape(Metanorma::Utils::to_ncname(pid))}\z/,
|
|
330
|
+
"")
|
|
331
|
+
else
|
|
332
|
+
id.sub(/_#{Regexp.escape(Metanorma::Utils::to_ncname(key))}\z/,
|
|
333
|
+
"")
|
|
334
|
+
end
|
|
335
|
+
final = if pid
|
|
336
|
+
"#{id}_#{Metanorma::Utils::to_ncname(key)}"
|
|
337
|
+
else
|
|
338
|
+
id
|
|
339
|
+
end
|
|
340
|
+
if !idx.key?(base)
|
|
341
|
+
idx[base] = { key: key, id: final, url: url }
|
|
342
|
+
elsif idx[base] && idx[base][:id] != final
|
|
343
|
+
idx[base] = nil
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
idx
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
# The member page's URL relative to the page being rendered; the index
|
|
351
|
+
# stores it collection-root-relative.
|
|
352
|
+
def hotspot_relative_url(url, docid)
|
|
353
|
+
@hotspot_rel_urls ||= {}
|
|
354
|
+
@hotspot_rel_urls[[url, docid]] ||= begin
|
|
355
|
+
cur = referencing_html_location(docid, false)
|
|
356
|
+
cur ? make_relative_path(cur, url) : url
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Address of the anchor record from the page being rendered.
|
|
361
|
+
def hotspot_target_href(rec, docid)
|
|
362
|
+
rec[:key] == docid and return "##{rec[:id]}"
|
|
363
|
+
rec[:url] or return nil
|
|
364
|
+
"#{hotspot_relative_url(rec[:url], docid)}##{rec[:id]}"
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
# Exact base first, then a unique prefix match: a declaration id
|
|
368
|
+
# carries the owning member's edition suffix chain behind the plain
|
|
369
|
+
# name (geometry_schema.cartesian_point_ISO_10303-42_2025_...), so
|
|
370
|
+
# the plain name resolves by prefix. Multiple equal-length matches
|
|
371
|
+
# are ambiguous and refuse, as do differing ids at the same key.
|
|
372
|
+
def hotspot_prefix_lookup(idx, prefix)
|
|
373
|
+
return idx[prefix] if idx[prefix]
|
|
374
|
+
|
|
375
|
+
candidates = idx.select { |k, r| r && k.start_with?("#{prefix}_") }
|
|
376
|
+
return nil if candidates.empty?
|
|
377
|
+
|
|
378
|
+
shortest = candidates.min_by { |k, _| k.length }
|
|
379
|
+
ties = candidates.count { |k, _| k.length == shortest[0].length }
|
|
380
|
+
ties == 1 ? shortest[1] : nil
|
|
381
|
+
end
|
|
109
382
|
end
|
|
110
383
|
end
|
|
111
384
|
end
|
data/lib/metanorma/version.rb
CHANGED
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
|
-
#
|
|
46
|
-
spec.add_dependency "relaton", "~> 3.
|
|
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.
|
|
4
|
+
version: 2.5.17
|
|
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-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|
|
@@ -212,14 +212,14 @@ dependencies:
|
|
|
212
212
|
requirements:
|
|
213
213
|
- - "~>"
|
|
214
214
|
- !ruby/object:Gem::Version
|
|
215
|
-
version:
|
|
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:
|
|
222
|
+
version: 3.1.1
|
|
223
223
|
description: Library to process any Metanorma standard.
|
|
224
224
|
email:
|
|
225
225
|
- open.source@ribose.com
|