metanorma 2.5.10 → 2.5.13
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 +7 -1
- data/Gemfile.devel +4 -4
- data/lib/metanorma/collection/manifest/manifest.rb +12 -0
- data/lib/metanorma/collection/renderer/fileprocess.rb +2 -2
- data/lib/metanorma/collection/renderer/renderer.rb +14 -0
- data/lib/metanorma/collection/renderer/utils.rb +50 -2
- data/lib/metanorma/compile/fragment_parallel.rb +55 -1
- data/lib/metanorma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e2bbe018164520f24a47304e5a543b33162f139617e751a7bd4a71f5bc4b8c8
|
|
4
|
+
data.tar.gz: cd865930cf21c065807ef2d2e357ce3ee41b1c35708ecdb69ea59eb59963f504
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 774a88cefafe5985f8868890f62e1ed552c51a9ffb64cd5b3744394dfe424650a2d32742b48238cb438e03a1ab658ff2681783ad8ed343fcf8d95bc6997ef180
|
|
7
|
+
data.tar.gz: fb5f625706d30499551cad94edad5f9aa4f604e3a60c4ab43c0baf3ff83c298d396db5724dc47f58f04545a2d8d0a45afed1fd0d87ad0fa753db09ba9867bc19
|
data/Gemfile
CHANGED
|
@@ -25,9 +25,15 @@ rescue StandardError
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
gem "debug"
|
|
28
|
-
gem "
|
|
28
|
+
gem "canon", "~> 0.3.122"
|
|
29
|
+
# lutaml-store 0.3.10 shipped conflict markers (lutaml-store#31); 0.3.11 fixes
|
|
30
|
+
gem "lutaml-store", "~> 0.3.11"
|
|
29
31
|
#gem "metanorma-iho"
|
|
30
32
|
#gem "metanorma-iso", ">= 3.2.0"
|
|
33
|
+
# Floor fontist at the variable-font indexing fix (fontist#531/#532):
|
|
34
|
+
# anything below 3.0.31 misses freshly installed variable fonts on
|
|
35
|
+
# locations lookups ("Fira Code" MissingFontError, metanorma-iho#563).
|
|
36
|
+
gem "fontist", "~> 3.0.32"
|
|
31
37
|
gem "mnconvert"
|
|
32
38
|
gem "pry"
|
|
33
39
|
gem "rake", "~> 13.0"
|
data/Gemfile.devel
CHANGED
|
@@ -9,15 +9,15 @@ gem "isodoc", github: "metanorma/isodoc", branch: "main"
|
|
|
9
9
|
gem "metanorma-iho", github: "metanorma/metanorma-iho", branch: "main"
|
|
10
10
|
gem "pubid", "~> 2.0.0.pre.alpha"
|
|
11
11
|
# The 1.9.356/0.5.13x pin pair worked around the leptris#1733 to_xml
|
|
12
|
-
# regression; retired — the
|
|
13
|
-
#
|
|
14
|
-
# leptris >= 1.9.
|
|
12
|
+
# regression; retired — moxml rides the 0.6 line (0.5 series gets no
|
|
13
|
+
# fixes; 0.6.0 removed the Opal surface, lutaml/moxml#516), which
|
|
14
|
+
# floors leptris >= 1.9.386 at load.
|
|
15
15
|
gem "leptris", "~> 1.9"
|
|
16
16
|
gem "relaton-cli", "~> 3.0.0.pre.alpha"
|
|
17
17
|
gem "glossarist", "~> 2.13"
|
|
18
18
|
gem "lutaml-model", "~> 0.8.107"
|
|
19
19
|
gem "metanorma-plugin-glossarist", "~> 0.5"
|
|
20
|
-
gem "moxml", "~> 0.
|
|
20
|
+
gem "moxml", "~> 0.6.0"
|
|
21
21
|
|
|
22
22
|
# Bridge: pubid 2.0.1 (and git main, until the PARG edition-2 migration
|
|
23
23
|
# lands) bakes grammars with the parsanol `mode` header alias, which
|
|
@@ -7,6 +7,11 @@ module Metanorma
|
|
|
7
7
|
class Manifest
|
|
8
8
|
# @return [Metanorma::Collection]
|
|
9
9
|
attr_reader :collection, :config, :lang, :script
|
|
10
|
+
# docref identifier replacements made during postprocessing: the
|
|
11
|
+
# original raw identifier (typically a GUID placeholder assigned to
|
|
12
|
+
# docrefs that declared none) mapped to the resolved identifier
|
|
13
|
+
# callers actually see (and that the file lookup keys entries by).
|
|
14
|
+
attr_reader :identifier_aliases
|
|
10
15
|
|
|
11
16
|
# @param level [String]
|
|
12
17
|
# @param dir [String]
|
|
@@ -17,6 +22,7 @@ module Metanorma
|
|
|
17
22
|
@collection = collection
|
|
18
23
|
@dir = dir
|
|
19
24
|
@disambig = ::Metanorma::Collection::Util::DisambigFiles.new
|
|
25
|
+
@identifier_aliases = {}
|
|
20
26
|
@config = manifest_postprocess(config)
|
|
21
27
|
end
|
|
22
28
|
|
|
@@ -57,6 +63,9 @@ module Metanorma
|
|
|
57
63
|
end
|
|
58
64
|
|
|
59
65
|
def manifest_identifier(config)
|
|
66
|
+
# capture before populate_id_from_doc: it replaces GUID identifiers
|
|
67
|
+
# in place, and the alias must map that original raw value.
|
|
68
|
+
original = config.identifier
|
|
60
69
|
no_id = populate_id_from_doc(config)
|
|
61
70
|
config.identifier =
|
|
62
71
|
if no_id && config.file # make file name be id
|
|
@@ -64,6 +73,9 @@ module Metanorma
|
|
|
64
73
|
else
|
|
65
74
|
@collection.class.resolve_identifier(config.identifier)
|
|
66
75
|
end
|
|
76
|
+
if original && original != config.identifier
|
|
77
|
+
@identifier_aliases[original] = config.identifier
|
|
78
|
+
end
|
|
67
79
|
Array(config.entry).each do |f|
|
|
68
80
|
manifest_identifier(f)
|
|
69
81
|
end
|
|
@@ -163,8 +163,8 @@ module Metanorma
|
|
|
163
163
|
# parent is selected, or a sliced reinflate ships index pages whose
|
|
164
164
|
# section pages are missing (iso-10303#811).
|
|
165
165
|
def render_member?(ident)
|
|
166
|
-
@
|
|
167
|
-
@
|
|
166
|
+
@only_member_keys.include?(ident) ||
|
|
167
|
+
@only_member_keys.include?(@files.get(ident, :parentid))
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
# Resume predicate: is this member already compiled and stored for its
|
|
@@ -139,6 +139,20 @@ module Metanorma
|
|
|
139
139
|
# list of files in the collection
|
|
140
140
|
@files = Metanorma::Collection::FileLookup.new(folder, self)
|
|
141
141
|
@files.add_section_split
|
|
142
|
+
# only_members carries the manifest's docref identifiers, but the
|
|
143
|
+
# file lookup keys entries by their resolved document identifiers
|
|
144
|
+
# (and section-split instances by "<docid> <title>"), so the
|
|
145
|
+
# selection must be translated into key space before the render
|
|
146
|
+
# loop - raw identifiers match nothing and the render skips every
|
|
147
|
+
# member while exiting zero (iso-10303#811's hollow artifact).
|
|
148
|
+
@only_member_keys =
|
|
149
|
+
if @only_members
|
|
150
|
+
aliases = collection.manifest.identifier_aliases || {}
|
|
151
|
+
@only_members.flat_map do |m|
|
|
152
|
+
resolved = aliases[m] || m
|
|
153
|
+
[resolved, @files.entry_key(resolved)]
|
|
154
|
+
end.compact.uniq
|
|
155
|
+
end
|
|
142
156
|
isodoc_populate
|
|
143
157
|
create_non_existing_directory(@outdir)
|
|
144
158
|
end
|
|
@@ -153,15 +153,63 @@ module Metanorma
|
|
|
153
153
|
::Metanorma::Util.log(error, :warning)
|
|
154
154
|
end
|
|
155
155
|
|
|
156
|
+
# Image relocation for collection rendering, in three ordered passes:
|
|
157
|
+
# anchor every image target at the document that emitted it, then
|
|
158
|
+
# inline SVGs, then encode what remains as data URIs.
|
|
156
159
|
def datauri_encode(docxml, directory)
|
|
160
|
+
anchor_image_targets(docxml, directory)
|
|
161
|
+
inline_svg_images(docxml, directory)
|
|
162
|
+
datauri_images(docxml, directory)
|
|
163
|
+
docxml
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Image targets are emitted relative to the document that carries them
|
|
167
|
+
# (metanorma#646). Each target must be anchored at the emitting
|
|
168
|
+
# document's directory BEFORE it is resolved: Vectory's datauri
|
|
169
|
+
# fallback tries the process working directory first, so a relative
|
|
170
|
+
# target was resolved against wherever the build happened to run --
|
|
171
|
+
# picking a same-named file from the wrong tree, or missing both
|
|
172
|
+
# bases and failing the render. Data URIs, remote URLs and absolute
|
|
173
|
+
# paths carry their own base and pass through; a target that anchors
|
|
174
|
+
# to an existing file is pinned to that absolute path, so only the
|
|
175
|
+
# file's bytes reach the output and the output is build-directory
|
|
176
|
+
# independent. A target that anchors to nothing keeps its emitted
|
|
177
|
+
# form, so a missing image stays a build-independent dangling
|
|
178
|
+
# reference.
|
|
179
|
+
def anchor_image_targets(docxml, directory)
|
|
180
|
+
docxml.xpath(ns("//image")).each do |i|
|
|
181
|
+
anchor_image_target(i, directory)
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def inline_svg_images(docxml, directory)
|
|
157
186
|
docxml.xpath(ns("//image")).each do |i|
|
|
158
187
|
read_in_if_svg(i, directory.sub(%r{(?<!=/)$}, "/"))
|
|
159
188
|
end
|
|
160
|
-
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def datauri_images(docxml, directory)
|
|
192
|
+
docxml.xpath(ns("//image")).each do |i|
|
|
161
193
|
(i["src"] && !i["src"].empty?) or next
|
|
162
194
|
i["src"] = Vectory::Utils::datauri(i["src"], directory)
|
|
163
195
|
end
|
|
164
|
-
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def anchor_image_target(img, directory)
|
|
199
|
+
src = img["src"]
|
|
200
|
+
anchorable_base?(src) or return
|
|
201
|
+
path = File.expand_path(src, directory)
|
|
202
|
+
File.file?(path) or return
|
|
203
|
+
img["src"] = path
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# A target whose base is already determined cannot be re-anchored.
|
|
207
|
+
def anchorable_base?(src)
|
|
208
|
+
return false if src.nil? || src.empty?
|
|
209
|
+
|
|
210
|
+
!(Vectory::Utils.datauri?(src) ||
|
|
211
|
+
Vectory::Utils.url?(src) ||
|
|
212
|
+
Vectory::Utils.absolute_path?(src))
|
|
165
213
|
end
|
|
166
214
|
|
|
167
215
|
def read_in_if_svg(img, localdir)
|
|
@@ -116,16 +116,70 @@ module Metanorma
|
|
|
116
116
|
lines = text.split("\n")
|
|
117
117
|
header, segments = segmentize(lines)
|
|
118
118
|
fragments = []
|
|
119
|
+
packer = fragment_packer(fragments, header)
|
|
119
120
|
segments.each do |seg|
|
|
120
121
|
if (mega = data2text_mega(seg))
|
|
122
|
+
packer.flush
|
|
121
123
|
mega_fragments(fragments, header, seg, mega)
|
|
122
124
|
else
|
|
123
|
-
|
|
125
|
+
packer.feed(seg[:lines])
|
|
124
126
|
end
|
|
125
127
|
end
|
|
128
|
+
packer.flush
|
|
126
129
|
fragments
|
|
127
130
|
end
|
|
128
131
|
|
|
132
|
+
# Pack consecutive segments into fragments of at least
|
|
133
|
+
# MIN_FRAG_BYTES source bytes: one fragment per clause multiplies
|
|
134
|
+
# the per-fragment fixed cost (relaton init, boilerplate, YAML
|
|
135
|
+
# loads — measured ~4s floor) by the clause count, which is a
|
|
136
|
+
# large LOSS on clause-dense documents with cheap clauses
|
|
137
|
+
# (jis-z-8301: 52 fragments, 2x slower than serial). Packing
|
|
138
|
+
# targets fragments substantial enough to amortise the fixed
|
|
139
|
+
# cost over workers x 2-3 fragments; documents whose clauses are
|
|
140
|
+
# already large are unaffected (one segment per fragment).
|
|
141
|
+
MIN_FRAG_BYTES = 40_000
|
|
142
|
+
|
|
143
|
+
# Accumulates consecutive whole segments across clause boundaries
|
|
144
|
+
# and emits fragments of at least MIN_FRAG_BYTES source bytes.
|
|
145
|
+
# Segments are never split: a boundary inside a clause separates
|
|
146
|
+
# the clause's heading from its subsections, and both halves then
|
|
147
|
+
# compile into morphed structures that lose their nested content.
|
|
148
|
+
class FragmentPacker
|
|
149
|
+
def initialize(min_bytes, &emit)
|
|
150
|
+
@min_bytes = min_bytes
|
|
151
|
+
@emit = emit
|
|
152
|
+
@buf = []
|
|
153
|
+
@bytes = 0
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def feed(seg_lines)
|
|
157
|
+
seg_bytes = seg_lines.sum { |l| l.bytesize + 1 }
|
|
158
|
+
if @bytes.positive? && @bytes >= @min_bytes
|
|
159
|
+
flush
|
|
160
|
+
end
|
|
161
|
+
@buf.concat(seg_lines)
|
|
162
|
+
@bytes += seg_bytes
|
|
163
|
+
if @bytes >= @min_bytes
|
|
164
|
+
flush
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def flush
|
|
169
|
+
return if @buf.empty?
|
|
170
|
+
|
|
171
|
+
@emit.call(@buf.dup)
|
|
172
|
+
@buf = []
|
|
173
|
+
@bytes = 0
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def fragment_packer(fragments, header, min_bytes: MIN_FRAG_BYTES)
|
|
178
|
+
FragmentPacker.new(min_bytes) do |body_lines|
|
|
179
|
+
fragments << new_fragment(fragments.size, header, body_lines)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
129
183
|
def new_fragment(i, header, body_lines)
|
|
130
184
|
path = File.join(@dir, "#{@prefix}-#{i}.adoc")
|
|
131
185
|
File.write(path, (header + body_lines).join("\n").concat("\n"),
|
data/lib/metanorma/version.rb
CHANGED
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.13
|
|
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-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|