metanorma 2.5.7 → 2.5.9

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: d73fd0dd05e3f13aecfe06da74c57bdba985c633ca55464d90ad8eef1d54c3ea
4
- data.tar.gz: 7b8c4a103f6ffce8d6a6234f18ef4f7e0cabf18af0c3aca9abec49e4e10255e8
3
+ metadata.gz: 5901d6f63360e485eec67b384b342a3bbd3e6e7c471a65eabd88d23dd54736b9
4
+ data.tar.gz: 1fdaced94e13cdef6904120007564fca55707f54a8bf1ec691b24fba8091de91
5
5
  SHA512:
6
- metadata.gz: 8927439c5072688f6df2e001e9a97611d5d1802047e4f5b1572412c0217e8eead1255ff97fe464efc16c669887ae861de4d0364109b40202b36ff0151c8998e2
7
- data.tar.gz: d45b9e9140271b2a4cfb6e9cef1a527ba13d69dceb07c9bd4181fd1b39f0180f319cb07858161e7e8683aeced2dd8c20a1b3a5ba222bec6b648a19dc01c06996
6
+ metadata.gz: b31a468f386fa605b3e7a97ac9e5e5d435a18898b11c22b151aa17041a108f23df0e27090a458d14d12c49b33c852e9ef5085de2d4e81b28c5a5dee3a4d7992e
7
+ data.tar.gz: 4520886b164a3f659ea267c519da26975a05c68141b7512f354b7ffc037a00bb43c2ce5c4540415cafe71e92be1e60686a54db9df72b3a335b625378ff429252
data/Gemfile CHANGED
@@ -8,6 +8,16 @@ gemspec
8
8
 
9
9
  gem "metanorma-core", ">= 0.2.5"
10
10
 
11
+ # taste stack the compile specs exercise: the oiml taste registers the
12
+ # flavor and lazily requires metanorma-oiml (OIML STS transformers,
13
+ # unreleased); mko main carries the model-side export entry.
14
+ # Lives here, not in Gemfile.devel: consumer workflows may rewrite the
15
+ # devel overlay (fontist CI appends its path pin to it), and the repo's
16
+ # own compile specs must not depend on its survival.
17
+ gem "metanorma-taste", "~> 1.1"
18
+ gem "metanorma-oiml", github: "metanorma/metanorma-oiml", branch: "main"
19
+ gem "metanorma-mko", github: "metanorma/metanorma-mko", branch: "main"
20
+
11
21
  begin
12
22
  eval_gemfile("Gemfile.devel")
13
23
  rescue StandardError
data/Gemfile.devel CHANGED
@@ -18,9 +18,16 @@ gem "glossarist", "~> 2.13"
18
18
  gem "lutaml-model", "~> 0.8.107"
19
19
  gem "metanorma-plugin-glossarist", "~> 0.5"
20
20
  gem "moxml", "~> 0.5"
21
- # taste stack the compile specs exercise: the oiml taste registers the
22
- # flavor and lazily requires metanorma-oiml (OIML STS transformers,
23
- # unreleased); mko main carries the model-side export entry
24
- gem "metanorma-taste", "~> 1.1"
25
- gem "metanorma-oiml", github: "metanorma/metanorma-oiml", branch: "main"
26
- gem "metanorma-mko", github: "metanorma/metanorma-mko", branch: "main"
21
+
22
+ # Bridge: pubid 2.0.1 (and git main, until the PARG edition-2 migration
23
+ # lands) bakes grammars with the parsanol `mode` header alias, which
24
+ # parsanol 1.3.113+ removed; pubid main's own floor (>= 1.3.114) admits
25
+ # the breaking 1.3.120, so collection specs fail with 13 rendering
26
+ # regressions. 1.3.114 is pubid's own floor and the last alias-accepting
27
+ # compiler. Drop this pin when pubid ships edition-2 artifacts.
28
+ gem "parsanol", "1.3.114"
29
+
30
+ # Bridge: svg_conform 0.2.5 was pushed with a compact-index checksum
31
+ # mismatch (Bundler::APIResponseMismatchError on every download); pin
32
+ # 0.2.4 until a corrected push lands.
33
+ gem "svg_conform", "0.2.4"
@@ -184,17 +184,33 @@ module Metanorma
184
184
  # param filepath [String]
185
185
  # @raise [AdocFileNotFoundException]
186
186
  def compile_adoc_file(file)
187
+ warn "BASEDIR-PROBE " + base_dir_options.inspect
187
188
  f = (Pathname.new file).absolute? ? file : File.join(@dir, file)
188
189
  File.exist?(f) or raise AdocFileNotFoundException.new "#{f} not found!"
189
190
  compile_adoc_file?(file) or return
190
191
  ::Metanorma::Util.log("[metanorma] Info: Compiling #{f}...", :warning)
191
192
  ::Metanorma::Compile.new
192
- .compile(f, agree_to_terms: true, install_fonts: false,
193
- extension_keys: [:xml])
193
+ .compile(f, { agree_to_terms: true, install_fonts: false,
194
+ extension_keys: [:xml] }.merge(base_dir_options))
194
195
  ::Metanorma::Util.log("[metanorma] Info: Compiling #{f}...done!",
195
196
  :warning)
196
197
  end
197
198
 
199
+ # Opt-in collection directive `base-dir: collection`: anchor the
200
+ # AsciiDoc include jail at the collection directory instead of the
201
+ # process working directory, so members compile identically from
202
+ # any working directory (metanorma#627). The anchor spans the whole
203
+ # collection, so member includes reaching above the member
204
+ # directory (../../../templates) stay inside the jail. The default
205
+ # (no directive) keeps today's working-directory anchoring, so
206
+ # existing builds stay byte-identical.
207
+ def base_dir_options
208
+ @collection.directives.detect do |d|
209
+ d.key == "base-dir" && d.value == "collection"
210
+ end or return {}
211
+ { base_dir: @collection.dirname }
212
+ end
213
+
198
214
  def compile_adoc_file?(file)
199
215
  !File.exist?(file.sub(/\.adoc$/, ".xml")) and return true
200
216
  @collection.directives.detect do |d|
@@ -120,6 +120,12 @@ module Metanorma
120
120
  @compile_options.merge!(bare: true)
121
121
  if @files.get(ident, :attachment) then copy_file_to_dest(ident)
122
122
  else
123
+ # Distributed reinflation: the manifest carries every member
124
+ # (their stored files feed the anchors and cross-reference
125
+ # passes) but this run renders only the selected slice; the
126
+ # other members' sections are rendered by sibling runs over
127
+ # the same store.
128
+ @only_members and !@only_members.include?(ident) and next
123
129
  file, fname = @files.targetfile_id(ident, read: true)
124
130
  @preserve_unresolved && member_stored?(ident, file) and next
125
131
  warn "\n\n\n\n\nProcess #{fname}: #{DateTime.now.strftime('%H:%M:%S')}"
@@ -101,6 +101,10 @@ module Metanorma
101
101
  # if false, this is the root instance of Renderer
102
102
  # if true, then this is not the last time Renderer will be run
103
103
  # (e.g. this is sectionsplit)
104
+ # Distributed reinflation: restrict the rendered members to these
105
+ # identifiers. The manifest still carries every member, so the
106
+ # anchors and cross-reference passes see the whole collection.
107
+ @only_members = options[:only_members]
104
108
  # Isolated/incremental build: preserve unresolved cross-document
105
109
  # references as stubs instead of resolving or stripping them, so each
106
110
  # member compiles independently and a later reinflation pass relinks.
@@ -276,8 +280,10 @@ module Metanorma
276
280
  font_options)
277
281
 
278
282
  mn2pdf = {
279
- font_manifest: ::Metanorma::Util::FontistHelper
280
- .location_manifest(@compile.processor, { fonts: fonts }),
283
+ font_manifest: ::Metanorma::Util::FontistHelper.location_manifest(
284
+ @compile.processor, { fonts: fonts },
285
+ continue_without_fonts: @compile_options[:continue_without_fonts],
286
+ ),
281
287
  }
282
288
  end
283
289
  [pres, { fonts: fonts, mn2pdf: mn2pdf }.compact]
@@ -190,7 +190,10 @@ module Metanorma
190
190
  p = Metanorma::Registry.instance.find_processor(Util::taste2flavor(flavor))
191
191
  if ::Metanorma::Util::FontistHelper.has_custom_fonts?(p, options, {})
192
192
  @fonts_manifest =
193
- ::Metanorma::Util::FontistHelper.location_manifest(p, options)
193
+ ::Metanorma::Util::FontistHelper.location_manifest(
194
+ p, options,
195
+ continue_without_fonts: options[:continue_without_fonts],
196
+ )
194
197
  end
195
198
  @options = options
196
199
  end
@@ -7,6 +7,7 @@ require "yaml"
7
7
  require "fontist"
8
8
  require "fontist/manifest"
9
9
  require "metanorma-taste"
10
+ require "metanorma/plugin/lutaml"
10
11
  require_relative "writeable"
11
12
  require_relative "validator"
12
13
  require_relative "compile_options"
@@ -28,6 +29,8 @@ module Metanorma
28
29
  include Flavor
29
30
  include Writeable
30
31
 
32
+ autoload :FragmentParallel, "metanorma/compile/fragment_parallel"
33
+
31
34
  DEFAULT_NUM_WORKERS = 3
32
35
 
33
36
  # @return [Array<String>]
@@ -52,6 +55,10 @@ module Metanorma
52
55
  # Step 1: Generate Semantic XML
53
56
  semantic_result = generate_semantic_xml(filename, options) or return nil
54
57
  source_file, semantic_xml = semantic_result
58
+ # All lutaml macros have expanded by the end of conversion; the
59
+ # plugin's retained XMI graphs (LRU-bounded, gigabytes for large
60
+ # models) are dead weight for every later phase. Flush them.
61
+ Metanorma::Plugin::Lutaml::CacheRegistry.clear_all
55
62
 
56
63
  # Step 2: Prepare output paths
57
64
  xml = Nokogiri::XML(semantic_xml, &:huge)
@@ -189,8 +196,13 @@ module Metanorma
189
196
  c.process_input_adoc_overrides(attrs, options)
190
197
  end
191
198
 
192
- def process_input_adoc_includes(file, filename)
199
+ def process_input_adoc_includes(file, filename, base_dir = nil)
193
200
  dir = File.dirname(filename)
201
+ # With an explicit asset anchor (base_dir), Asciidoctor resolves
202
+ # include targets against that anchor rather than the working
203
+ # directory, so the docfile-directory prefix must be absolute for
204
+ # includes to stay docfile-anchored from any working directory.
205
+ base_dir and dir = File.expand_path(dir)
194
206
  dir != "." and
195
207
  file = file.gsub(/^include::/, "include::#{dir}/")
196
208
  .gsub(/^embed::/, "embed::#{dir}/")
@@ -198,10 +210,19 @@ module Metanorma
198
210
  end
199
211
 
200
212
  def process_input_adoc(filename, options)
213
+ if (w = ENV["METANORMA_PARALLEL_CLAUSES"].to_i) >= 2
214
+ # Fragment-based parallel semantic compile (spike, #620): split,
215
+ # compile the fragments in worker processes, stitch. The stitched
216
+ # semantic XML rejoins the ordinary output pipeline below.
217
+ Util.log("[metanorma] Processing: AsciiDoc input" \
218
+ " (fragment-parallel, #{w} workers).", :info)
219
+ return [read_file(filename),
220
+ FragmentParallel.new(filename, options, w).run]
221
+ end
201
222
  Util.log("[metanorma] Processing: AsciiDoc input.", :info)
202
223
  file = read_file(filename)
203
224
  file = process_input_adoc_hdr(file, options)
204
- file = process_input_adoc_includes(file, filename)
225
+ file = process_input_adoc_includes(file, filename, options[:base_dir])
205
226
  update_options_after_preprocessing(file, options)
206
227
  [file, @processor.input_to_isodoc(file, filename, options)]
207
228
  end
@@ -200,8 +200,10 @@ module Metanorma
200
200
 
201
201
  ext == :pdf && custom_fonts and
202
202
  ret[:mn2pdf] = {
203
- font_manifest: Util::FontistHelper
204
- .location_manifest(@processor, ret),
203
+ font_manifest: Util::FontistHelper.location_manifest(
204
+ @processor, ret,
205
+ continue_without_fonts: options[:continue_without_fonts],
206
+ ),
205
207
  }
206
208
  end
207
209
  end
@@ -0,0 +1,685 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "yaml"
5
+
6
+ module Metanorma
7
+ class Compile
8
+ # Spike: fragment-based parallel semantic compilation (metanorma#620).
9
+ #
10
+ # Opt in with METANORMA_PARALLEL_CLAUSES=<N> (N >= 2; default off). The
11
+ # AsciiDoc source is split into clause fragments, each fragment is
12
+ # compiled to semantic XML by a worker forked off this process, and
13
+ # the fragment XMLs are stitched back into one semantic document that
14
+ # the ordinary output pipeline consumes as today.
15
+ #
16
+ # Forking over spawning: a fresh interpreter per fragment re-pays the
17
+ # flavor boot and -- fatally for vocabulary corpora -- the glossarist
18
+ # dataset load (tens of seconds per fragment). A forked worker
19
+ # inherits everything the parent already loaded. Before the first
20
+ # fork, the parent preloads the document's glossarist datasets once
21
+ # (opt-in plugin store cache, METANORMA_GLOSSARIST_SHARED_DATASETS),
22
+ # so the workers read the loaded models copy-on-write instead of
23
+ # re-parsing them.
24
+ #
25
+ # Split rules:
26
+ # - includes are resolved inline, recursively;
27
+ # - text before the first top-level heading (document header, preamble,
28
+ # floating-title forewords) belongs to the first fragment;
29
+ # - each top-level (`==`) clause is one fragment;
30
+ # - a clause whose body is a single `[yaml2text,<file>,<var>]` block
31
+ # over an array-valued YAML file is split further: each fragment
32
+ # repeats the clause's heading chain and the block template verbatim,
33
+ # but feeds it a generated YAML file holding one chunk of entries.
34
+ # That is what makes vocabulary corpora (per-schema terms loops)
35
+ # parallelisable without understanding their expansion.
36
+ #
37
+ # Stitching merges root-level children by element name: preface,
38
+ # sections, bibliography and metanorma-extension children are merged
39
+ # (wrapper clauses carrying the same anchor or title are unified;
40
+ # non-wrapper duplicates are dropped), annex/indexsect/colophon are
41
+ # appended in source order. Auto-generated boilerplate (foreword,
42
+ # boilerplate) is taken from the first fragment only.
43
+ #
44
+ # Known spike gaps: per-fragment validation is skipped (the stitched
45
+ # document flows through the normal pipeline, where validation and
46
+ # presentation run as today); bibitem pruning that keys on citations
47
+ # sees only the owning fragment's citations; shorthand `<<bibitem>>`
48
+ # references to bibitems declared in another fragment degrade to
49
+ # xref; glossarist <concept> cross-references to terms owned by
50
+ # another fragment degrade to <errormsg> unless the reference is
51
+ # unqualified and the repair pass can reconstruct it (domain-qualified
52
+ # concept resolution needs the glossarist dataset, which no fragment
53
+ # holds for the whole document); generated element ids differ between
54
+ # any two compiles, so stitched output is canon-equivalent to a serial
55
+ # compile (identical modulo generated ids and whitespace-only text at
56
+ # splice points), not byte-identical.
57
+ class FragmentParallel
58
+ HEADING1 = /^==(?!=)/.freeze
59
+ STYLE_ATTR = /^(\[\[.+?\]\]|\[[^\[\]]+\])$/.freeze
60
+ FRAME_TITLE = /^\.[^\s]/.freeze
61
+ INCLUDE = /^include::(\S+?)\[\]\s*$/.freeze
62
+ # [yaml2text,file,var] and [data2text,var=file]
63
+ DATA2TEXT = /\[(yaml2text|data2text),(.+?)\]\s*$/.freeze
64
+ MAX_INCLUDE_DEPTH = 8
65
+
66
+ # Mirrors the plugin's DatasetPreprocessor header directive.
67
+ DATASET_ATTR = /^:glossarist-dataset:\s*(.*)$/.freeze
68
+
69
+ # The metanorma-plugin-glossarist store-cache gate (its
70
+ # DatasetRegistry::SHARED_STORE_ENV; spelled out here because the
71
+ # plugin may be absent entirely).
72
+ SHARED_DATASETS_ENV = "METANORMA_GLOSSARIST_SHARED_DATASETS"
73
+
74
+ SKIP_ROOT = %w[bibdata boilerplate].freeze
75
+ MERGE_ROOT = %w[preface sections bibliography
76
+ metanorma-extension].freeze
77
+ WRAPPERS = %w[clause terms references introduction].freeze
78
+ NONBASE_PREFACE_SKIP = %w[foreword].freeze
79
+ # Canonical root-child order of metanorma semantic XML (standoc emits
80
+ # bibliography last, annexes after sections); the stitch reorders to
81
+ # match, since fragments append in source order.
82
+ ROOT_ORDER = %w[bibdata metanorma-extension boilerplate preface
83
+ sections annex indexsect colophon bibliography].freeze
84
+
85
+ def initialize(filename, _options, workers)
86
+ @filename = filename
87
+ @workers = workers
88
+ @dir = File.realpath(File.dirname(File.expand_path(filename)))
89
+ @base = File.basename(filename, ".*")
90
+ @prefix = ".#{@base}.frag"
91
+ end
92
+
93
+ def run
94
+ text = resolve_includes(
95
+ File.read(@filename, encoding: "utf-8"), 0
96
+ )
97
+ fragments = build_fragments(text)
98
+ warn "[fragment-parallel] #{@filename}: #{fragments.size} fragments," \
99
+ " #{@workers} workers"
100
+ warm_shared_datasets(text)
101
+ compile_fragments(fragments)
102
+ t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
103
+ xml = stitch(fragments.map { |f| f[:path].sub(/\.adoc$/, ".xml") })
104
+ warn format("[fragment-parallel] stitched in %.1fs",
105
+ Process.clock_gettime(Process::CLOCK_MONOTONIC) - t)
106
+ xml
107
+ ensure
108
+ cleanup
109
+ end
110
+
111
+ private
112
+
113
+ # -- splitting
114
+
115
+ def build_fragments(text)
116
+ lines = text.split("\n")
117
+ header, segments = segmentize(lines)
118
+ fragments = []
119
+ segments.each do |seg|
120
+ if (mega = data2text_mega(seg))
121
+ mega_fragments(fragments, header, seg, mega)
122
+ else
123
+ fragments << new_fragment(fragments.size, header, seg[:lines])
124
+ end
125
+ end
126
+ fragments
127
+ end
128
+
129
+ def new_fragment(i, header, body_lines)
130
+ path = File.join(@dir, "#{@prefix}-#{i}.adoc")
131
+ File.write(path, (header + body_lines).join("\n").concat("\n"),
132
+ encoding: "UTF-8")
133
+ { path: path, lines: header + body_lines }
134
+ end
135
+
136
+ # Returns [header_lines, [{lines:}, ...]]; header is everything
137
+ # before the first segment boundary. A boundary opens at a top-level
138
+ # heading, an include, or a run of attribute/anchor/frame-title lines
139
+ # immediately preceding one; the heading itself is part of that
140
+ # segment and does not open another.
141
+ def segmentize(lines)
142
+ bounds = []
143
+ i = 0
144
+ while i < lines.size
145
+ if boundary_start(lines, i)
146
+ # the boundary opens at the attribute-run start (or the bare
147
+ # heading); blank lines separating the previous clause travel
148
+ # with the fragment that follows them, so inter-clause
149
+ # spacing survives the split
150
+ b = i
151
+ b -= 1 while b.positive? && lines[b - 1].strip.empty?
152
+ bounds << b
153
+ i = boundary_start_resume(lines, i) || lines.size
154
+ else
155
+ i += 1
156
+ end
157
+ end
158
+ return [[], [{ lines: lines }]] if bounds.empty?
159
+
160
+ header = lines[0...bounds.first]
161
+ segs = bounds.each_with_index.map do |b, k|
162
+ { lines: lines[b...(bounds[k + 1] || lines.size)] }
163
+ end
164
+ [header, segs]
165
+ end
166
+
167
+ # Index where the boundary scan resumes: past the heading/include
168
+ # that closes the attribute run opened at +i+.
169
+ def boundary_start_resume(lines, i)
170
+ return i + 1 if seg_boundary_line?(lines[i])
171
+
172
+ j = i
173
+ loop do
174
+ j += 1
175
+ j += 1 while j < lines.size && lines[j].strip.empty?
176
+ return j + 1 if j < lines.size && seg_boundary_line?(lines[j])
177
+ return nil unless j < lines.size &&
178
+ (lines[j].match?(STYLE_ATTR) ||
179
+ lines[j].match?(FRAME_TITLE))
180
+ end
181
+ end
182
+
183
+ # Index of the heading/include that closes the attribute run
184
+ # opening at line +i+, or nil when lines[i] opens no boundary.
185
+ def boundary_start(lines, i)
186
+ return i if seg_boundary_line?(lines[i])
187
+
188
+ return nil unless lines[i].match?(STYLE_ATTR) ||
189
+ lines[i].match?(FRAME_TITLE)
190
+
191
+ j = i
192
+ loop do
193
+ j += 1
194
+ j += 1 while j < lines.size && lines[j].strip.empty?
195
+ return nil if j >= lines.size
196
+ return j if seg_boundary_line?(lines[j])
197
+ return nil unless lines[j].match?(STYLE_ATTR) ||
198
+ lines[j].match?(FRAME_TITLE)
199
+ end
200
+ end
201
+
202
+ def seg_boundary_line?(line)
203
+ line.match?(HEADING1) || line.match?(INCLUDE)
204
+ end
205
+
206
+ def resolve_includes(text, depth, base = @dir)
207
+ return text if depth >= MAX_INCLUDE_DEPTH
208
+
209
+ text.gsub(INCLUDE) do
210
+ inc = Regexp.last_match[1]
211
+ path = File.expand_path(inc, base)
212
+ if File.exist?(path)
213
+ resolve_includes(File.read(path, encoding: "utf-8"), depth + 1,
214
+ File.dirname(path))
215
+ else
216
+ Regexp.last_match[0]
217
+ end
218
+ end
219
+ end
220
+
221
+ # A segment is mega-splittable when it holds exactly one
222
+ # yaml2text/data2text open block whose data file parses to an
223
+ # array of at least two entries.
224
+ def data2text_mega(seg)
225
+ attr_i = seg[:lines].each_index.find do |i|
226
+ seg[:lines][i].match?(DATA2TEXT)
227
+ end
228
+ return nil unless attr_i
229
+
230
+ m = seg[:lines][attr_i].match(DATA2TEXT)
231
+ delim = seg[:lines][attr_i + 1]
232
+ return nil unless delim && delim.match?(/^-{4,}$/)
233
+
234
+ close = ((attr_i + 2)...seg[:lines].size).find do |j|
235
+ seg[:lines][j] == delim
236
+ end
237
+ return nil unless close
238
+
239
+ file, var = parse_data2text_args(m[2])
240
+ return nil unless file && var
241
+
242
+ data_path = File.expand_path(file, @dir)
243
+ return nil unless File.exist?(data_path)
244
+
245
+ begin
246
+ entries = YAML.safe_load(File.read(data_path))
247
+ rescue Psych::SyntaxError
248
+ return nil
249
+ end
250
+ return nil unless entries.is_a?(Array) && entries.size >= 2
251
+
252
+ { attr_i: attr_i, close: close, delim: delim, kind: m[1],
253
+ template: seg[:lines][(attr_i + 2)...close],
254
+ var: var, entries: entries, data_path: data_path }
255
+ end
256
+
257
+ # "[yaml2text,]file,var" or "[data2text,]var=file" -> [file, var].
258
+ # The data file is the argument naming an existing YAML file.
259
+ def parse_data2text_args(raw)
260
+ if raw.include?(",")
261
+ a, b = raw.split(",", 2)
262
+ [[b, a], [a, b]].each do |file, var|
263
+ return [file, var] if data_file_arg?(file) && ident_arg?(var)
264
+ end
265
+ [nil, nil]
266
+ elsif (p = raw.split("=", 2)).size == 2
267
+ data_file_arg?(p[1]) && ident_arg?(p[0]) ? [p[1], p[0]] : [nil, nil]
268
+ else
269
+ [nil, nil]
270
+ end
271
+ end
272
+
273
+ def data_file_arg?(arg)
274
+ arg.match?(/\.ya?ml\z/i) && File.exist?(File.expand_path(arg, @dir))
275
+ end
276
+
277
+ def ident_arg?(arg)
278
+ arg.match?(/\A[A-Za-z_][A-Za-z0-9_]*\z/)
279
+ end
280
+
281
+ def mega_fragments(fragments, header, seg, mega)
282
+ # one chunk per worker: the chunks left over after the first wave
283
+ # land on workers that just finished, keeping every worker fed
284
+ chunks = [mega[:entries].size, @workers].min
285
+ size = (mega[:entries].size / chunks.to_f).ceil
286
+ head = header + seg[:lines][0...mega[:attr_i]]
287
+ base_idx = fragments.size
288
+ mega[:entries].each_slice(size).with_index do |slice, i|
289
+ idx = base_idx + i
290
+ data_name = "#{@prefix}-#{idx}.data.yaml"
291
+ data_path = File.join(@dir, data_name)
292
+ File.write(data_path, YAML.dump(slice), encoding: "UTF-8")
293
+ directive = if mega[:kind] == "data2text"
294
+ "[data2text,#{mega[:var]}=#{data_name}]"
295
+ else
296
+ "[yaml2text,#{data_name},#{mega[:var]}]"
297
+ end
298
+ path = File.join(@dir, "#{@prefix}-#{idx}.adoc")
299
+ File.write(path, [
300
+ head,
301
+ directive,
302
+ mega[:delim], mega[:template], mega[:delim],
303
+ ].flatten.join("\n").concat("\n"), encoding: "UTF-8")
304
+ fragments << { path: path, mega: true }
305
+ end
306
+ end
307
+
308
+ # -- dataset preload
309
+
310
+ # Load the document's glossarist datasets once, in this process,
311
+ # before any worker is forked. The plugin's opt-in store cache
312
+ # (METANORMA_GLOSSARIST_SHARED_DATASETS) memoizes the parsed
313
+ # datasets process-wide; the forked workers then answer their own
314
+ # registry lookups from the shared, copy-on-write models instead of
315
+ # re-parsing tens of thousands of YAML files per fragment.
316
+ #
317
+ # Skipped without the plugin, or when the datasets cannot be
318
+ # resolved: the fragments then behave exactly as on the spike --
319
+ # each loads what it needs, in its own fork.
320
+ def warm_shared_datasets(text)
321
+ return unless defined?(Metanorma::Plugin::Glossarist::DatasetRegistry)
322
+ return unless Metanorma::Plugin::Glossarist::DatasetRegistry
323
+ .respond_to?(:shared_store_for)
324
+
325
+ paths = glossarist_dataset_paths(text)
326
+ return if paths.empty?
327
+
328
+ # An explicit "0" is a user opt-out: leave the plugin gate off
329
+ # and skip the preload -- the workers re-load per fork, as before.
330
+ gate = ENV.fetch(SHARED_DATASETS_ENV, nil)
331
+ gate = ENV[SHARED_DATASETS_ENV] = "1" if gate.nil? || gate.empty?
332
+ return if gate == "0"
333
+
334
+ registry = Metanorma::Plugin::Glossarist::DatasetRegistry.new
335
+ t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
336
+ paths.each { |p| registry.concepts_at(p) }
337
+ # Give the workers a compacted, shared heap to fork from.
338
+ GC.start
339
+ warn format("[fragment-parallel] preloaded %d glossarist dataset(s)" \
340
+ " in %.1fs; workers share them copy-on-write",
341
+ paths.size,
342
+ Process.clock_gettime(Process::CLOCK_MONOTONIC) - t)
343
+ rescue StandardError => e
344
+ warn "[fragment-parallel] glossarist dataset preload skipped:" \
345
+ " #{e.message}"
346
+ end
347
+
348
+ # Registered dataset paths in document-header order, resolved
349
+ # against the docfile directory the same way the plugin resolves
350
+ # them for a fragment (:glossarist-dataset: name:path;name:path).
351
+ def glossarist_dataset_paths(text)
352
+ text.scan(DATASET_ATTR)
353
+ .flat_map { |(contexts)| contexts.split(";") }
354
+ .filter_map do |entry|
355
+ _, rel = entry.split(":", 2)&.map(&:strip)
356
+ next unless rel && !rel.empty?
357
+
358
+ path = File.expand_path(rel, @dir)
359
+ File.directory?(path) ? path : nil
360
+ end.uniq
361
+ end
362
+
363
+ # -- compilation
364
+
365
+ # Bounded fork scheduler: keep @workers children alive until the
366
+ # fragments run out, reap any exited child, then raise the first
367
+ # failure after all scheduled work has drained.
368
+ def compile_fragments(fragments)
369
+ return compile_fragments_in_process(fragments) unless fork?
370
+
371
+ queue = fragments.dup
372
+ running = {}
373
+ failure = nil
374
+ until queue.empty? && running.empty?
375
+ until queue.empty? || running.size >= @workers
376
+ f = queue.shift
377
+ begin
378
+ t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
379
+ running[spawn_fragment(f)] = [f, t]
380
+ rescue StandardError => e
381
+ failure ||= e.message
382
+ end
383
+ end
384
+ break if running.empty?
385
+
386
+ pid, status = Process.waitpid2(-1, 0)
387
+ f, t = running.delete(pid)
388
+ next unless f
389
+
390
+ warn format("[fragment-parallel] [%d/%d] %s %.1fs",
391
+ fragments.size - queue.size - running.size,
392
+ fragments.size, File.basename(f[:path]),
393
+ Process.clock_gettime(Process::CLOCK_MONOTONIC) - t)
394
+ unless status.success?
395
+ failure ||= "fragment compile failed" \
396
+ " (#{status.exitstatus || "signal #{status.termsig}"}):" \
397
+ " #{f[:path]}, see #{f[:path]}.log"
398
+ end
399
+ end
400
+ raise failure if failure
401
+ end
402
+
403
+ # No fork on this platform (Windows): compile serially in-process,
404
+ # capturing each fragment's output in its log like a forked child's.
405
+ # Slower, same artifacts and failure semantics.
406
+ def compile_fragments_in_process(fragments)
407
+ clauses_env = ENV["METANORMA_PARALLEL_CLAUSES"]
408
+ ENV["METANORMA_PARALLEL_CLAUSES"] = nil
409
+ out = $stdout.dup
410
+ err = $stderr.dup
411
+ fragments.each_with_index do |f, i|
412
+ t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
413
+ failure = nil
414
+ File.open("#{f[:path]}.log", "w:UTF-8") do |log|
415
+ $stdout.reopen(log)
416
+ $stderr.reopen(log)
417
+ begin
418
+ compile_fragment(f)
419
+ $stdout.flush
420
+ $stderr.flush
421
+ rescue StandardError => e
422
+ failure = StandardError.new(
423
+ "fragment compile failed: #{f[:path]}: #{e.message}",
424
+ )
425
+ failure.set_backtrace(e.backtrace)
426
+ end
427
+ end
428
+ $stdout.reopen(out)
429
+ $stderr.reopen(err)
430
+ warn format("[fragment-parallel] [%d/%d] %s %.1fs",
431
+ i + 1, fragments.size, File.basename(f[:path]),
432
+ Process.clock_gettime(Process::CLOCK_MONOTONIC) - t)
433
+ raise failure if failure
434
+ end
435
+ ensure
436
+ ENV["METANORMA_PARALLEL_CLAUSES"] = clauses_env
437
+ $stdout.reopen(out)
438
+ $stderr.reopen(err)
439
+ end
440
+
441
+ def fork?
442
+ Process.respond_to?(:fork)
443
+ end
444
+
445
+ # Fork one worker for +f+. The child rebinds stdout/stderr to the
446
+ # fragment log, drops this env var so the nested compile does not
447
+ # recurse into fragment-parallel again, and exits without running
448
+ # the parent's at-exit handlers: the parent owns the run's
449
+ # lifecycle.
450
+ def spawn_fragment(f)
451
+ log = File.open("#{f[:path]}.log", "w:UTF-8")
452
+ if (pid = Process.fork).nil?
453
+ $stdout.reopen(log)
454
+ $stderr.reopen(log)
455
+ log.close
456
+ ENV["METANORMA_PARALLEL_CLAUSES"] = nil
457
+ begin
458
+ compile_fragment(f)
459
+ $stdout.flush
460
+ $stderr.flush
461
+ exit!(0)
462
+ rescue StandardError => e
463
+ warn e.full_message
464
+ exit!(1)
465
+ end
466
+ end
467
+ log.close
468
+ pid
469
+ end
470
+
471
+ # The child-side body of one fragment compile. Runs in a forked copy
472
+ # of this process: the flavor libraries, the metanorma registry and
473
+ # the preloaded glossarist datasets are all inherited, so the
474
+ # fragment pays only its own expansion and conversion.
475
+ def compile_fragment(f)
476
+ Metanorma::Compile.new.compile(
477
+ f[:path], format: :asciidoc, extension_keys: [:xml],
478
+ novalid: true, agree_to_terms: true
479
+ )
480
+ end
481
+
482
+ # -- stitching
483
+
484
+ def stitch(paths)
485
+ base = parse(paths.first)
486
+ ns = base.root.namespace&.href
487
+ paths[1..].each do |p|
488
+ stitch_fragment_root(base, parse(p), ns)
489
+ end
490
+ reorder_root(base)
491
+ repair_concept_refs(base, ns)
492
+ base.to_xml
493
+ end
494
+
495
+ # Concept cross-references whose target term lives in another
496
+ # fragment fail resolution inside that fragment and come back as
497
+ # <errormsg> payloads carrying the reference texts verbatim. This
498
+ # pass repairs the unqualified subset: when the referenced id (or
499
+ # its glossarist "term-" prefixed anchor) names a term in the
500
+ # assembled document, the resolved refterm/renderterm/xref form is
501
+ # reconstructed. Domain-qualified references (the bulk in the
502
+ # iso-10303-2 corpus) resolve through the glossarist dataset, which
503
+ # the stitched document does not carry -- those remain errormsg and
504
+ # are the spike's principal known gap.
505
+ def repair_concept_refs(base, ns)
506
+ terms = base.root.xpath(".//xmlns:term[@anchor]", xmlns: ns)
507
+ .each_with_object({}) { |t, m| m[t["anchor"]] = t }
508
+ repaired = 0
509
+ base.root.xpath(".//xmlns:concept/xmlns:errormsg", xmlns: ns)
510
+ .each do |err|
511
+ tts = err.xpath(".//xmlns:tt", xmlns: ns).map(&:text)
512
+ next unless tts.size == 3
513
+
514
+ # the error payload carries the raw concept id; the rendered
515
+ # anchor carries the glossarist "term-" prefix
516
+ id = tts[2]
517
+ id = "term-#{id}" unless terms.key?(id)
518
+ next unless terms.key?(id)
519
+
520
+ refterm = base.document.create_element("refterm")
521
+ refterm.content = tts[0]
522
+ renderterm = base.document.create_element("renderterm")
523
+ renderterm.content = tts[1]
524
+ xref = base.document.create_element("xref")
525
+ xref["target"] = id
526
+ err.replace(refterm)
527
+ refterm.next = renderterm
528
+ renderterm.next = xref
529
+ repaired += 1
530
+ end
531
+ warn "[fragment-parallel] repaired #{repaired} cross-fragment" \
532
+ " concept references" if repaired.positive?
533
+ end
534
+
535
+ # Merge one fragment's root into +base+. Layout note: standoc emits
536
+ # root children adjacent, with a newline after the root open tag and
537
+ # one before the root close; whitespace-only text travels with the
538
+ # element it precedes/follows, so appends reproduce the fragment's
539
+ # own layout at the splice point.
540
+ def stitch_fragment_root(base, d, ns)
541
+ pairs = []
542
+ ws = +""
543
+ d.root.children.each do |c|
544
+ if c.text?
545
+ ws << c.text
546
+ else
547
+ pairs << [ws, c]
548
+ ws = +""
549
+ end
550
+ end
551
+ last = nil
552
+ pairs.each do |lead, el|
553
+ name = el.name
554
+ if SKIP_ROOT.include?(name)
555
+ last = :skip
556
+ elsif MERGE_ROOT.include?(name) &&
557
+ (t = base.root.at_xpath("./xmlns:#{name}", xmlns: ns))
558
+ merge_children(t, el, ns, name)
559
+ last = :merge
560
+ else
561
+ drop_trailing_ws(base.root)
562
+ base.root.add_child(
563
+ base.root.document.create_text_node(lead)
564
+ ) unless lead.empty?
565
+ adopt(base, el, ns).each { |n| base.root.add_child(n) }
566
+ last = :append
567
+ end
568
+ end
569
+ return unless last == :append && !ws.empty?
570
+
571
+ drop_trailing_ws(base.root)
572
+ base.root.add_child(base.root.document.create_text_node(ws))
573
+ end
574
+
575
+ def drop_trailing_ws(root)
576
+ t = root.children.last
577
+ t.remove if t&.text? && t.text.strip.empty?
578
+ end
579
+
580
+ # Root children are emitted in the canonical semantic-XML order;
581
+ # each element keeps the whitespace-only text node that preceded it.
582
+ # Everything is detached and re-added in order: libxml2's in-place
583
+ # node moves do not reliably reposition text nodes.
584
+ def reorder_root(base)
585
+ pairs = []
586
+ ws = nil
587
+ base.root.children.each do |c|
588
+ if c.text? && c.text.strip.empty?
589
+ ws = c
590
+ else
591
+ pairs << [ws, c]
592
+ ws = nil
593
+ end
594
+ end
595
+ rank = ->(p, i) { [ROOT_ORDER.index(p[1].name) || ROOT_ORDER.size, i] }
596
+ ordered = pairs.sort_by.with_index { |p, i| rank.call(p, i) }
597
+ base.root.children.each(&:remove)
598
+ ordered.each do |lead, el|
599
+ base.root.add_child(
600
+ base.root.document.create_text_node(lead.text)
601
+ ) if lead
602
+ base.root.add_child(el)
603
+ end
604
+ base.root.add_child(
605
+ base.root.document.create_text_node(ws.text)
606
+ ) if ws
607
+ end
608
+
609
+ def parse(path)
610
+ Nokogiri::XML(File.read(path, encoding: "UTF-8"), &:huge)
611
+ end
612
+
613
+ # Copy `el` (from another document) into `base`'s document, dropping
614
+ # the default-namespace declaration so it inherits the target's.
615
+ def adopt(base, el, ns)
616
+ s = el.to_xml
617
+ s = s.gsub(%r{ xmlns="#{Regexp.quote(ns)}"}, "") if ns
618
+ Nokogiri::XML::DocumentFragment.new(base.document, s).children
619
+ end
620
+
621
+ def merge_children(base_el, frag_el, ns, rootname)
622
+ skip = rootname == "preface" ? NONBASE_PREFACE_SKIP : []
623
+ pending = +""
624
+ landed = false
625
+ frag_el.children.each do |child|
626
+ if child.text?
627
+ pending << child.text
628
+ next
629
+ end
630
+ twin = base_el.elements.find { |c| elem_key(c, ns) ==
631
+ elem_key(child, ns) }
632
+ if skip.include?(child.name)
633
+ pending = +""
634
+ elsif twin && WRAPPERS.include?(child.name)
635
+ base_el.add_child(
636
+ base_el.document.create_text_node(pending)
637
+ ) unless pending.empty?
638
+ pending = +""
639
+ landed = true
640
+ merge_children(twin, child, ns, rootname)
641
+ elsif twin
642
+ # duplicate generated metadata or boilerplate: keep base's
643
+ pending = +""
644
+ else
645
+ base_el.add_child(
646
+ base_el.document.create_text_node(pending)
647
+ ) unless pending.empty?
648
+ pending = +""
649
+ landed = true
650
+ adopt(base_el.document, child, ns).each do |n|
651
+ base_el.add_child(n)
652
+ end
653
+ end
654
+ end
655
+ return unless landed && !pending.empty?
656
+
657
+ # trailing whitespace of the fragment's own layout
658
+ base_el.add_child(base_el.document.create_text_node(pending))
659
+ end
660
+
661
+ # Wrapper clauses of the same mega-clause carry the same explicit
662
+ # anchor, or -- when the source names no anchor -- the same title.
663
+ def elem_key(el, ns)
664
+ return [el.name, "##{el['anchor']}"] if el["anchor"]
665
+
666
+ t = ns ? el.at_xpath("./xmlns:title", xmlns: ns) : el.at("./title")
667
+ [el.name, t&.text]
668
+ end
669
+
670
+ def cleanup
671
+ return if ENV["METANORMA_PARALLEL_KEEP"] == "1"
672
+
673
+ # every artifact of this run carries the run prefix (fragment
674
+ # sources, chunk data files, fragment XML, child logs, the
675
+ # glossarist per-document log)
676
+ Dir.glob("#{@dir}/#{@prefix}-*").each do |p|
677
+ File.unlink(p) if File.file?(p)
678
+ rescue Errno::EACCES
679
+ # Windows can hold a just-closed file briefly (indexer/AV);
680
+ # a leftover temp artifact is harmless
681
+ end
682
+ end
683
+ end
684
+ end
685
+ end
@@ -156,10 +156,10 @@ module Metanorma
156
156
  to: File.dirname(output_paths[:out]),
157
157
  presentation_xml: presentation)
158
158
  rescue LoadError => e
159
- @log.add_msg("MKO_OUTPUT" => { category: "MKO Output",
160
- error: "the mko output format requires " \
161
- "the metanorma-mko gem: %s",
162
- severity: 0 })
159
+ @log.add_msg(MKO_OUTPUT: { category: "MKO Output",
160
+ error: "the mko output format requires " \
161
+ "the metanorma-mko gem: %s",
162
+ severity: 0 })
163
163
  @log.add("MKO_OUTPUT", nil, params: [e.message])
164
164
  nil
165
165
  end
@@ -182,7 +182,7 @@ module Metanorma
182
182
  # behind; collect it before the next extension stacks its own.
183
183
  GC.start
184
184
  rescue StandardError => e
185
- isodoc_error_process(e, strict_error?(ext, isodoc_options), false)
185
+ isodoc_error_process(e)
186
186
  end
187
187
 
188
188
  # Process format directly from semantic XML
@@ -192,7 +192,7 @@ module Metanorma
192
192
  GC.start
193
193
  true # Return as Thread equivalent
194
194
  rescue StandardError => e
195
- isodoc_error_process(e, strict_error?(ext, isodoc_options), true)
195
+ isodoc_error_process(e)
196
196
  ext != :presentation
197
197
  end
198
198
 
@@ -214,31 +214,22 @@ module Metanorma
214
214
 
215
215
  private
216
216
 
217
- # A presentation failure is always strict: every downstream format
218
- # needs the presentation XML. The :strict option arrives as a
219
- # boolean from the CLI but as a string from document attributes, so
220
- # accept both (the two rescue sites previously each checked only
221
- # one form).
222
- def strict_error?(ext, isodoc_options)
223
- ext == :presentation ||
224
- [true, "true"].include?(isodoc_options[:strict])
225
- end
226
-
227
- # On the strict path the message is pooled into @errors for the
228
- # caller to surface (the standalone CLI reports the pool and
229
- # aborts; the collection renderer attributes it to the failed
230
- # member, #586). The class+message line is also printed here in all
231
- # cases, so it sits adjacent to its backtrace in the build log: a
232
- # pooled message surfaces only at end of run, and a bare backtrace
233
- # mid-log is undiagnosable. The exception class is retained because
234
- # for errors like Encoding::UndefinedConversionError it carries
235
- # half the diagnosis.
236
- def isodoc_error_process(err, strict, must_abort)
217
+ # An output stage that raises has not produced its artifact, so the
218
+ # failure must reach the caller however Compile is consumed: the
219
+ # message is pooled into @errors unconditionally (#601) — the
220
+ # standalone CLI reports the pool and aborts, so a missing artifact
221
+ # can never pair with exit code 0; the collection renderer
222
+ # attributes it to the failed member (#586). The class+message line
223
+ # is also printed here in all cases, so it sits adjacent to its
224
+ # backtrace in the build log: a pooled message surfaces only at end
225
+ # of run, and a bare backtrace mid-log is undiagnosable. The
226
+ # exception class is retained because for errors like
227
+ # Encoding::UndefinedConversionError it carries half the diagnosis.
228
+ def isodoc_error_process(err)
237
229
  msg = "#{err.class}: #{err.message}"
238
- strict || err.message.include?("Fatal:") and @errors << msg
230
+ @errors << msg
239
231
  puts msg
240
232
  puts err.backtrace.join("\n")
241
- must_abort and 1
242
233
  end
243
234
  end
244
235
  end
@@ -102,6 +102,25 @@ module Metanorma
102
102
  @@updated_formulas_repo = true
103
103
  install_fonts_safe(manifest, agree, continue, no_progress)
104
104
  end
105
+
106
+ # Fontist raises MissingFontError for any manifest font that is not
107
+ # installed locally, even after install_fonts_safe has honoured
108
+ # --continue-without-fonts for the install itself (#595): the flag's
109
+ # promise would be defeated one call later. Drop the missing font
110
+ # from the manifest with a warning, so mn2pdf renders with
111
+ # substituted fonts; without the flag the error stays fatal.
112
+ def locate_manifest(manifest, continue_without_fonts)
113
+ instance = Fontist::Manifest.from_hash(manifest, locations: true)
114
+ instance&.to_hash
115
+ rescue Fontist::Errors::MissingFontError => e
116
+ raise unless continue_without_fonts
117
+
118
+ Util.log("[fontist] '#{e.font}' font is missing. " \
119
+ "Continuing without it (--continue-without-fonts).",
120
+ :warning)
121
+ rest = manifest.reject { |name, _| name == e.font }
122
+ rest.empty? ? {} : locate_manifest(rest, continue_without_fonts)
123
+ end
105
124
  end
106
125
 
107
126
  def self.install_fonts(processor, options)
@@ -132,7 +151,8 @@ module Metanorma
132
151
  || source_attributes[:fonts]
133
152
  end
134
153
 
135
- def self.location_manifest(processor, source_attributes)
154
+ def self.location_manifest(processor, source_attributes,
155
+ continue_without_fonts: false)
136
156
  base = if processor.respond_to?(:fonts_manifest) &&
137
157
  !processor.fonts_manifest.nil?
138
158
  processor.fonts_manifest.dup
@@ -142,12 +162,8 @@ module Metanorma
142
162
 
143
163
  return nil if base.empty? && !source_attributes[:fonts]
144
164
 
145
- instance = Fontist::Manifest.from_hash(
146
- append_source_fonts(base, source_attributes),
147
- locations: true,
148
- )
149
-
150
- instance.to_hash unless instance.nil?
165
+ locate_manifest(append_source_fonts(base, source_attributes),
166
+ continue_without_fonts)
151
167
  end
152
168
 
153
169
  def self.append_source_fonts(manifest, source_attributes)
@@ -11,6 +11,8 @@ module Metanorma
11
11
  def init_vars(workers)
12
12
  @workers = workers
13
13
  @queue = SizedQueue.new(@workers)
14
+ @mutex = Mutex.new
15
+ @exceptions = []
14
16
  end
15
17
 
16
18
  def init_thread
@@ -18,21 +20,38 @@ module Metanorma
18
20
  catch(:exit) do
19
21
  loop do
20
22
  job, args = @queue.pop
21
- job.call *args
23
+ run_job job, args
22
24
  end
23
25
  end
24
26
  end
25
27
  end
26
28
 
29
+ # A job that raises must not take its worker thread down: the
30
+ # thread stays in the loop, so jobs scheduled behind the failure
31
+ # still run, and the exception is held for shutdown to re-raise
32
+ # in the calling thread (#601). A dead worker here would deadlock
33
+ # shutdown on a saturated queue and strand the remaining jobs.
34
+ def run_job(job, args)
35
+ job.call *args
36
+ rescue StandardError => e
37
+ @mutex.synchronize { @exceptions << e }
38
+ end
39
+
27
40
  def schedule(*args, &block)
28
41
  @queue << [block, args]
29
42
  end
30
43
 
44
+ # Drain the queue, join every worker, then propagate the first
45
+ # job exception to the caller: a raising job must fail the run
46
+ # that scheduled it, never exit 0.
31
47
  def shutdown
32
48
  @workers.times do
33
49
  schedule { throw :exit }
34
50
  end
35
51
  @threads.map(&:join)
52
+ return if @exceptions.empty?
53
+
54
+ raise @exceptions.first
36
55
  end
37
56
  end
38
57
  end
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.5.7".freeze
2
+ VERSION = "2.5.9".freeze
3
3
  end
data/metanorma.gemspec CHANGED
@@ -26,12 +26,16 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_runtime_dependency "asciidoctor"
28
28
  spec.add_runtime_dependency "concurrent-ruby"
29
- spec.add_runtime_dependency "fontist", ">= 2.1.2"
29
+ spec.add_runtime_dependency "fontist", "~> 3.0"
30
30
  spec.add_runtime_dependency "htmlentities"
31
- spec.add_runtime_dependency "isodoc", ">= 3.5.0"
31
+ spec.add_runtime_dependency "isodoc", "~> 3.5"
32
32
  spec.add_runtime_dependency "marcel"
33
33
  spec.add_runtime_dependency "metanorma-core"
34
- spec.add_runtime_dependency "metanorma-standoc", ">= 3.5.0"
34
+ # metanorma-plugin-lutaml is required by Metanorma::Compile: the XMI
35
+ # macro caches are flushed at the conversion/output phase boundary
36
+ # (CacheRegistry shipped in 0.7.46)
37
+ spec.add_runtime_dependency "metanorma-plugin-lutaml", "~> 0.7.46"
38
+ spec.add_runtime_dependency "metanorma-standoc", "~> 3.5"
35
39
  spec.add_runtime_dependency "mn2pdf", "~> 2"
36
40
  spec.add_runtime_dependency "nokogiri"
37
41
  spec.add_development_dependency "canon" #, "= 0.2.3"
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.7
4
+ version: 2.5.9
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-10-30 00:00:00.000000000 Z
11
+ date: 2026-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: fontist
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.1.2
47
+ version: '3.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.2
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: htmlentities
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: isodoc
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.5.0
75
+ version: '3.5'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 3.5.0
82
+ version: '3.5'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: marcel
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -108,20 +108,34 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: metanorma-plugin-lutaml
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.7.46
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.7.46
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: metanorma-standoc
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - ">="
129
+ - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: 3.5.0
131
+ version: '3.5'
118
132
  type: :runtime
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - ">="
136
+ - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: 3.5.0
138
+ version: '3.5'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: mn2pdf
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -264,6 +278,7 @@ files:
264
278
  - lib/metanorma/compile/compile_options.rb
265
279
  - lib/metanorma/compile/extract.rb
266
280
  - lib/metanorma/compile/flavor.rb
281
+ - lib/metanorma/compile/fragment_parallel.rb
267
282
  - lib/metanorma/compile/output_filename.rb
268
283
  - lib/metanorma/compile/output_filename_config.rb
269
284
  - lib/metanorma/compile/relaton_drop.rb