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 +4 -4
- data/lib/metanorma-utils.rb +1 -0
- data/lib/utils/stable_uuid.rb +24 -0
- data/lib/utils/version.rb +1 -1
- data/lib/utils/xml.rb +9 -3
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d02c080014b8cabcfeaa0e9ed6c6aaa0c3eaa2f577785ff2fff1f0e2a38f4e9
|
|
4
|
+
data.tar.gz: d02010244c01b3c5f08575ff928a00a947cafc36389410632c5f21adccb7e215
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58ae304620ccfac55ec0d88a4c06f3c48b25770103439d73b95746399a8acabd73292a262fed529b0eeb5a791ba1bfdf7de0889b5d23aaf42b07c2bf1c4ea960
|
|
7
|
+
data.tar.gz: 19f07d138c5cdb0b85486fec3891a80eb0b6c0ca5ca1f70a0c14870b2960cf4329530cefc344eb1ffdfca19b5500064367339beb373c377e145f1b7155d944f2
|
data/lib/metanorma-utils.rb
CHANGED
|
@@ -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
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
|
-
|
|
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
|
-
|
|
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.
|
|
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-
|
|
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
|