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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c943a0079f13ed34fde3579d6bfff1ee1d85e66022c6ddf4322952b013a8cf48
4
- data.tar.gz: 3ca79d870842cee7c10740e3d998b0aa00eb6018ccbfa5ad264b2f22064d1d6e
3
+ metadata.gz: 5b7f24f8333462e860db4b5e24a6e92f48da2c2ce8dc53f42d0b91da79ffbd9b
4
+ data.tar.gz: b3496f8ce83f4ccdc72b7f757b12ad2108d938de33764b5a7e6be86426f15ffe
5
5
  SHA512:
6
- metadata.gz: 149568613e29da651a52912be1ecc0383b32ed4a46c629b7ec2730bc0b4723debbcc701c19d34d6b049d5f99ef38d7ed11069a4e4d7573864b674ec9f1c735ab
7
- data.tar.gz: 198f1c36770f1f2ebb308492ae32331c6b0c4b5e84e77dcda25b155f9c27abd9932ae904d3fbaeb1537d1dcf367842f5494b077e64bb5596ef3d193ad5542d51
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
- # 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.
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
- return idx[prefix] if idx[prefix]
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
- candidates = idx.select { |k, r| r && k.start_with?("#{prefix}_") }
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 { |k, _| k.length }
412
- ties = candidates.count { |k, _| k.length == shortest[0].length }
413
- ties == 1 ? shortest[1] : nil
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
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.5.22".freeze
2
+ VERSION = "2.5.24".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.22
4
+ version: 2.5.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.