metanorma 2.5.22 → 2.5.24
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/lib/metanorma/collection/renderer/svg.rb +45 -11
- data/lib/metanorma/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5b7f24f8333462e860db4b5e24a6e92f48da2c2ce8dc53f42d0b91da79ffbd9b
|
|
4
|
+
data.tar.gz: b3496f8ce83f4ccdc72b7f757b12ad2108d938de33764b5a7e6be86426f15ffe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bc44aaac9aed93d4f70d7a31e15874f8fc37a13d6e222d5f24d5d36dddd7ba8cb1f60e218c574e4be835c8fc309669c3e51f4f03fa1c346f93dfc6ecc42c27f
|
|
7
|
+
data.tar.gz: de64618a5753ed9cf54632ccc79847dc19f836ad805ec7d04f18389eb358ca246d54b63066cfd5bde11db9a46093c8b8b0f862837291aca40ad9c0be9287f1fa
|
|
@@ -51,6 +51,14 @@ module Metanorma
|
|
|
51
51
|
# Stage 1: Resolve EREF references to their targets
|
|
52
52
|
resolve_svgmap_erefs(docxml, tag, isodoc, ids, presxml, docid)
|
|
53
53
|
|
|
54
|
+
# Stage 1a: svgmap erefs bind through the reference-anchor
|
|
55
|
+
# resolvers at EVERY stage — schema-doc pages carry synthesized
|
|
56
|
+
# svgmap items (expressir 2.4.64+ formats the __expressg remark
|
|
57
|
+
# with its item list) and render outside the reinflate; without
|
|
58
|
+
# this pass their hotspots emit as bare unbound links
|
|
59
|
+
# (iso-10303#844).
|
|
60
|
+
resolve_svgmap_erefs_via_resolvers(docxml, docid, ids)
|
|
61
|
+
|
|
54
62
|
# Stage 1b: Re-key the svgmap xref targets that a reinflated render
|
|
55
63
|
# carries from the staging build: they name anchors in the compile-
|
|
56
64
|
# time document shape, which on a sectionsplit page sit behind this
|
|
@@ -207,12 +215,18 @@ module Metanorma
|
|
|
207
215
|
x.name = "link"
|
|
208
216
|
x["target"] = href
|
|
209
217
|
end
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
resolve_svgmap_erefs_via_resolvers(docxml, docid, ids)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# Binds svgmap erefs through the registered reference-anchor
|
|
222
|
+
# resolvers. Where a domain's references are ALSO declared as page
|
|
223
|
+
# anchors, that domain registers a resolver mapping the reference
|
|
224
|
+
# identity to an anchor record; core registers none and carries no
|
|
225
|
+
# domain knowledge. Resolvers receive (reference_name, lookup),
|
|
226
|
+
# where lookup maps a plain anchor base to a record. Unresolvable
|
|
227
|
+
# erefs are left untouched.
|
|
228
|
+
def resolve_svgmap_erefs_via_resolvers(docxml, docid, _ids)
|
|
229
|
+
idx = hotspot_anchor_index
|
|
216
230
|
lookup = ->(base) { hotspot_prefix_lookup(idx, base) }
|
|
217
231
|
docxml.xpath(ns("//svgmap/target/eref[@bibitemid]")).each do |e|
|
|
218
232
|
rec = self.class.reference_anchor_resolvers.lazy.map do |resolver|
|
|
@@ -402,15 +416,35 @@ module Metanorma
|
|
|
402
416
|
# name (geometry_schema.cartesian_point_ISO_10303-42_2025_...), so
|
|
403
417
|
# the plain name resolves by prefix. Multiple equal-length matches
|
|
404
418
|
# are ambiguous and refuse, as do differing ids at the same key.
|
|
419
|
+
# Memoized per prefix: the index is immutable once built, and a
|
|
420
|
+
# mega-member's svgmap erefs hit this per stage pass (the linear
|
|
421
|
+
# scan showed up at 24%+ of a 104-style render's wall).
|
|
405
422
|
def hotspot_prefix_lookup(idx, prefix)
|
|
406
|
-
|
|
423
|
+
@hotspot_prefix_memo ||= {}
|
|
424
|
+
@hotspot_prefix_memo.fetch(prefix) do
|
|
425
|
+
@hotspot_prefix_memo[prefix] =
|
|
426
|
+
idx[prefix] || prefix_lookup_scan(idx, prefix)
|
|
427
|
+
end
|
|
428
|
+
end
|
|
407
429
|
|
|
408
|
-
|
|
430
|
+
# Candidate keys sharing the prefix, by binary search over the
|
|
431
|
+
# sorted index keys: keys with the stem prefix are contiguous in
|
|
432
|
+
# sort order, so the slice between the lower bound and the first
|
|
433
|
+
# non-matching key is the entire candidate set.
|
|
434
|
+
def prefix_lookup_scan(idx, prefix)
|
|
435
|
+
stem = "#{prefix}_"
|
|
436
|
+
keys = hotspot_sorted_keys(idx)
|
|
437
|
+
lo = keys.bsearch_index { |k| k >= stem } or return nil
|
|
438
|
+
candidates = keys[lo..].take_while { |k| k.start_with?(stem) }
|
|
409
439
|
return nil if candidates.empty?
|
|
410
440
|
|
|
411
|
-
shortest = candidates.min_by
|
|
412
|
-
ties = candidates.count { |k
|
|
413
|
-
ties == 1 ? shortest
|
|
441
|
+
shortest = candidates.min_by(&:length)
|
|
442
|
+
ties = candidates.count { |k| k.length == shortest.length }
|
|
443
|
+
ties == 1 ? idx[shortest] : nil
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def hotspot_sorted_keys(idx)
|
|
447
|
+
@hotspot_sorted_keys ||= idx.keys.select { |k| idx[k] }.sort
|
|
414
448
|
end
|
|
415
449
|
end
|
|
416
450
|
end
|
data/lib/metanorma/version.rb
CHANGED