metanorma-utils 2.0.12 → 2.0.14

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: 0c1e1dcd39f422719231a463baad92a7cfb2774836497b5b862c9baa1bf457f1
4
- data.tar.gz: a665005b573ead115c5304f1ddaa675070dd73b5563e120046610133fa3f2690
3
+ metadata.gz: 2d02c080014b8cabcfeaa0e9ed6c6aaa0c3eaa2f577785ff2fff1f0e2a38f4e9
4
+ data.tar.gz: d02010244c01b3c5f08575ff928a00a947cafc36389410632c5f21adccb7e215
5
5
  SHA512:
6
- metadata.gz: 35ab1ff450498d18369cb240313c830347a8d90dee2c6a690341901ddc6bf00f64fe2797501df48777d0858b5ee409ee91d1a98842048bcd56de07807749625c
7
- data.tar.gz: 15e6daaa1c5c2a8db6ae670d0f045465f65fa001e24632592515b31ca71cd4149eb1f03082272df45104b333f64bff7172518ae8ed4781ef0e6bf9d91faffedc
6
+ metadata.gz: 58ae304620ccfac55ec0d88a4c06f3c48b25770103439d73b95746399a8acabd73292a262fed529b0eeb5a791ba1bfdf7de0889b5d23aaf42b07c2bf1c4ea960
7
+ data.tar.gz: 19f07d138c5cdb0b85486fec3891a80eb0b6c0ca5ca1f70a0c14870b2960cf4329530cefc344eb1ffdfca19b5500064367339beb373c377e145f1b7155d944f2
@@ -8,6 +8,7 @@ require_relative "utils/xml"
8
8
  require_relative "utils/anchor"
9
9
  require_relative "utils/anchor_ranges"
10
10
  require_relative "utils/random_uuid"
11
+ require_relative "utils/stable_uuid"
11
12
  require_relative "utils/htmlentities_patch"
12
13
  require_relative "utils/gc_budget"
13
14
  require_relative "utils/asciidoctor_table_buffer"
@@ -0,0 +1,24 @@
1
+ require "uuidtools"
2
+
3
+ module Metanorma
4
+ module Utils
5
+ # Namespace for the deterministic identifier mint: the same name
6
+ # always produces the same UUIDv5.
7
+ STABLE_UUID_NAMESPACE = UUIDTools::UUID.parse_raw(
8
+ [0x8d, 0x3c, 0x51, 0x93, 0x9e, 0x0c, 0x4f, 0x4d, 0x9c, 0xa3,
9
+ 0x71, 0x9c, 0x2b, 0x4f, 0x3e, 0xd2].pack("C*")
10
+ )
11
+
12
+ class << self
13
+ # A deterministic identifier: the same parts always produce the
14
+ # same UUID. Recompiling a document must produce the same
15
+ # element ids (isodoc#861 - the random mint made every compile's
16
+ # HTML differ).
17
+ def stable_uuid(*parts)
18
+ UUIDTools::UUID
19
+ .sha1_create(STABLE_UUID_NAMESPACE, parts.compact.join("\0"))
20
+ .to_s
21
+ end
22
+ end
23
+ end
24
+ end
data/lib/utils/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "2.0.12".freeze
3
+ VERSION = "2.0.14".freeze
4
4
  end
5
5
  end
data/lib/utils/xml.rb CHANGED
@@ -52,7 +52,12 @@ module Metanorma
52
52
  # large compiles. Fragments off the shared document are
53
53
  # independent trees; conversion is single-threaded.
54
54
  def noko(_script = "Latn", &block)
55
- fragment = noko_template.fragment("")
55
+ # DocumentFragment.new without input skips the per-call parse:
56
+ # fragment("") minted a ParseOptions and ran a parse pass on
57
+ # the empty string for every call (73k per plateau compile,
58
+ # 30% of this method's wall time, measured). The built
59
+ # serialization is byte-identical.
60
+ fragment = Nokogiri::XML::DocumentFragment.new(noko_template)
56
61
  ::Nokogiri::XML::Builder.with fragment, &block
57
62
  fragment
58
63
  .to_xml(encoding: "UTF-8", indent: 0,
@@ -88,8 +93,9 @@ module Metanorma
88
93
  def noko_html(&block)
89
94
  # Fragments off the shared template are independent trees, like in
90
95
  # #noko: duplicating the whole scaffold document per call buys
91
- # nothing and copies every node of it.
92
- fragment = noko_template.fragment("")
96
+ # nothing and copies every node of it. No-input new skips the
97
+ # per-call parse, as in #noko.
98
+ fragment = Nokogiri::XML::DocumentFragment.new(noko_template)
93
99
  ::Nokogiri::XML::Builder.with fragment, &block
94
100
  fragment.to_xml(encoding: "UTF-8", indent: 0,
95
101
  save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.12
4
+ version: 2.0.14
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-12 00:00:00.000000000 Z
11
+ date: 2026-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -320,6 +320,7 @@ files:
320
320
  - lib/utils/main.rb
321
321
  - lib/utils/namespace.rb
322
322
  - lib/utils/random_uuid.rb
323
+ - lib/utils/stable_uuid.rb
323
324
  - lib/utils/version.rb
324
325
  - lib/utils/xml.rb
325
326
  - metanorma-utils.gemspec