metanorma 2.5.4 → 2.5.5

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: 4f36a841296240362316b293a3353c54b85b83485b81d21e762d639fe26ce100
4
- data.tar.gz: 7302ecaa3bbf5893fa6a0c52199ce7080475efb00a9973fe8e21ace651a996b8
3
+ metadata.gz: 66371f7ab35ebb13e3b57cd0dbbaa3ef8a9c0c5d57e99efe4bd1c3452d4055f0
4
+ data.tar.gz: 6bade47b39a3b31a3f74cea3fb119196dd4bf6d87356d39af3f17a5c7dd0fb8e
5
5
  SHA512:
6
- metadata.gz: b9d143219d4f9a9130321c675e3b1bc8f5966dcb09961f13527381d493e7d6a6e7efffce28bd807bf5a07b2ae040048a321f498a8d15ecab002a756d8c493f8a
7
- data.tar.gz: fd1c20bd7b7d1062130781c1276b95b921a9408d4da2a17d622f5b21053b8a20ab168daa710bfbdefbc652901bea7d5e7c75e891e7a1fb91d2dd74075edbe39b
6
+ metadata.gz: 88a35f0eb4334353cb0ae728b82b489ed75514d037b05c66a404d15e230090d10b64dc149487dc65a6f5abb8531807e9b707ec4015de773bf63685f6ae0dc18a
7
+ data.tar.gz: 9ef18c46695f5789fb89e697aeeebb14ef271f411dd11ddecb4a898b3138075fb354f0ece2f1b885987b7d9a852e4627f78f9887c23ee0a605a67325204f9c65
data/Gemfile CHANGED
@@ -6,6 +6,9 @@ git_source(:github) { |repo| "https://github.com/#{repo}" }
6
6
 
7
7
  gemspec
8
8
 
9
+ # TEMPORARY cross-PR pin (metanorma-core#18): Compile resolves via Core::Flavors
10
+ gem "metanorma-core", github: "metanorma/metanorma-core", branch: "feat/flavor-table"
11
+
9
12
  begin
10
13
  eval_gemfile("Gemfile.devel")
11
14
  rescue StandardError
data/Gemfile.devel ADDED
@@ -0,0 +1,10 @@
1
+ # Local development pins (eval'd by Gemfile; not committed workflow state)
2
+ gem "metanorma-document", github: "metanorma/metanorma-document", branch: "feat/model-validation-l1-declarations"
3
+ gem "metanorma-standoc", github: "metanorma/metanorma-standoc", branch: "feat/move-standard-document"
4
+ gem "metanorma-iso", github: "metanorma/metanorma-iso", branch: "feat/model-validation-migration"
5
+ gem "isodoc", github: "metanorma/isodoc", branch: "main"
6
+ gem "pubid", ">= 2.0.0.pre.alpha.9"
7
+ gem "relaton-cli", ">= 3.0.0.pre.alpha.1"
8
+ gem "glossarist", "~> 2.13"
9
+ gem "lutaml-model", "~> 0.8.0", "< 0.8.20"
10
+ gem "metanorma-plugin-glossarist", "0.3.9"
@@ -145,6 +145,12 @@ module Metanorma
145
145
  end
146
146
 
147
147
  def update_filepaths(entry, prefix)
148
+ # `manifest_expand_yaml_entry` hands us the loaded sub-manifest's
149
+ # `entry` collection directly, which is an Array of entries.
150
+ if entry.is_a?(Array)
151
+ entry.each { |e| update_filepaths(e, prefix) }
152
+ return
153
+ end
148
154
  entry.file && !(Pathname.new entry.file).absolute? and
149
155
  entry.file = File.join(prefix, entry.file)
150
156
  entry&.entry&.each do |f|
@@ -98,9 +98,7 @@ module Metanorma
98
98
  end
99
99
 
100
100
  def taste2flavor(taste)
101
- tastes = Metanorma::TasteRegister.instance.aliases
102
- tastes[taste.to_sym] and taste = tastes[taste.to_sym]
103
- taste
101
+ ::Metanorma::Core::FlavorLoader.taste2flavor(taste)
104
102
  end
105
103
 
106
104
  def taste2isodoc_attrs(taste, format)
@@ -39,7 +39,13 @@ module Metanorma
39
39
  end
40
40
 
41
41
  def options_in_file(filename)
42
+ # the adoc preprocessing path re-extracts options from a Tempfile
43
+ filename = filename.path if filename.is_a?(Tempfile)
42
44
  content = read_file(filename)
45
+ # XML inputs carry no AsciiDoc header options; booting the adoc
46
+ # pipeline for them only drags every plugin into the compile.
47
+ return extract_xml_options(content) if filename.end_with?(".xml")
48
+
43
49
  Metanorma::Input::Asciidoc.new.extract_metanorma_options(content)
44
50
  .merge(extract_xml_options(content))
45
51
  end
@@ -74,20 +80,34 @@ module Metanorma
74
80
  Metanorma::TasteRegister.document_transformers_for(taste) || {}
75
81
  end
76
82
 
77
- # The processor's output formats merged with the suffixes of any
78
- # taste-contributed document-model formats, so those formats pass
79
- # extension validation and get an output suffix.
83
+ # Harness formats available to every flavor, regardless of the
84
+ # processor's own list. MKO (metanorma-document) is resolved via
85
+ # Core::Flavors, so it needs nothing from the flavor gems.
86
+ HARNESS_OUTPUT_FORMATS = { mko: "mko" }.freeze
87
+
88
+ # Formats a flavor offers by default: its own list plus
89
+ # taste-contributed document-model formats. The harness formats
90
+ # (mko) are deliberately absent — they are opt-in via
91
+ # --extensions, never a surprise default output.
92
+ def default_output_formats(options)
93
+ @processor.output_formats
94
+ .merge(
95
+ taste_transformers(options)
96
+ .transform_values { |spec| spec[:suffix] }.compact,
97
+ )
98
+ end
99
+
100
+ # The default formats merged with the harness formats, so those
101
+ # pass extension validation and get an output suffix.
80
102
  def effective_output_formats(options)
81
- @processor.output_formats.merge(
82
- taste_transformers(options)
83
- .transform_values { |spec| spec[:suffix] }.compact,
84
- )
103
+ default_output_formats(options).merge(HARNESS_OUTPUT_FORMATS)
85
104
  end
86
105
 
87
106
  # Whether +ext+ is generated from presentation XML, honouring both the
88
107
  # processor's own answer and a taste transformer's +:presentation+ flag.
89
108
  def uses_presentation_xml?(ext, options)
90
- @processor.use_presentation_xml(ext) ||
109
+ ext == :mko || # unit numbering comes from the presentation model
110
+ @processor.use_presentation_xml(ext) ||
91
111
  (taste_transformers(options)[ext] || {})[:presentation] == true
92
112
  end
93
113
 
@@ -98,13 +118,19 @@ module Metanorma
98
118
  end and ext << :presentation
99
119
  !ext.include?(:rxl) && options[:site_generate] and
100
120
  ext << :rxl
121
+ # Keep options[:extension_keys] in sync: get_isodoc_options filters
122
+ # output_formats by extension_keys, and presentation is an implicit
123
+ # dependency of html/doc/pdf — if it is only on the local +ext+ array,
124
+ # the filter strips it from the formats table (and, when the processor
125
+ # hands out a live hash, permanently from the flavor config).
126
+ options[:extension_keys] = ext
101
127
  ext
102
128
  end
103
129
 
104
130
  def extract_extensions(options)
105
131
  formats = effective_output_formats(options)
106
132
  options[:extension_keys] ||=
107
- formats.reduce([]) { |memo, (k, _)| memo << k }
133
+ default_output_formats(options).reduce([]) { |memo, (k, _)| memo << k }
108
134
  options[:extension_keys].reduce([]) do |memo, e|
109
135
  if formats[e] then memo << e
110
136
  else
@@ -134,8 +160,14 @@ module Metanorma
134
160
  get_isodoc_fileparams(options, ret)
135
161
  copy_isodoc_options_attrs(options, ret)
136
162
  font_manifest_mn2pdf(options, ret, ext)
137
- ret[:output_formats]&.select! do |k, _|
138
- options[:extension_keys].include?(k)
163
+ # Filter a COPY — never select! the processor's live formats table.
164
+ # Generic (and any flavor that returns configuration.formats directly)
165
+ # would otherwise permanently lose :presentation after the first
166
+ # html/doc request that did not list presentation in extension_keys.
167
+ if ret[:output_formats]
168
+ keys = options[:extension_keys] || []
169
+ ret[:output_formats] = ret[:output_formats]
170
+ .select { |k, _| keys.include?(k) }
139
171
  end
140
172
  ret[:log] = @log
141
173
  ret
@@ -2,16 +2,25 @@
2
2
 
3
3
  module Metanorma
4
4
  class Compile
5
+ # Thin adapter: taste resolution reads the core table; gem loading
6
+ # stays on FlavorLoader so the existing SystemExit / processor-
7
+ # registration contract is byte-identical to main.
5
8
  module Flavor
6
9
  def load_flavor(stdtype)
7
- Metanorma::Core::FlavorLoader.load_flavor(stdtype)
10
+ Metanorma::Core::FlavorLoader.load_flavor(taste2flavor(stdtype))
8
11
  end
9
12
 
10
13
  def taste2flavor(stdtype)
14
+ entry = Metanorma::Core::Flavors.find(stdtype)
15
+ return entry.base_flavor if entry&.taste?
16
+
11
17
  Metanorma::Core::FlavorLoader.taste2flavor(stdtype)
12
18
  end
13
19
 
14
20
  def stdtype2flavor_gem(stdtype)
21
+ entry = Metanorma::Core::Flavors.find(stdtype)
22
+ return entry.gem if entry && !entry.taste?
23
+
15
24
  Metanorma::Core::FlavorLoader.stdtype2flavor_gem(stdtype)
16
25
  end
17
26
  end
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  class Compile
3
- NO_FONTIST_FORMATS = %i[xml presentation rxl].freeze
3
+ NO_FONTIST_FORMATS = %i[xml presentation rxl mko].freeze
4
4
 
5
5
  # Generate presentation XML from semantic XML
6
6
  def generate_presentation_xml(source_file, xml, bibdata, output_paths, opt)
@@ -109,6 +109,10 @@ module Metanorma
109
109
  end
110
110
  FileUtils.cp f, output_paths[:presentationxml]
111
111
  true
112
+ elsif ext == :mko
113
+ # Harness format: export the MKO bundle from the typed model
114
+ export_mko_bundle(output_paths)
115
+ true
112
116
  elsif ext == :html && options[:sectionsplit]
113
117
  # Special case: Split HTML into sections
114
118
  sectionsplit_convert(
@@ -120,6 +124,32 @@ module Metanorma
120
124
  end
121
125
  end
122
126
 
127
+ # Export the MKO machine serialization (metanorma-document). The
128
+ # semantic and presentation XML are already on disk by the time this
129
+ # runs; Mko resolves the flavor model via the Core::Flavors registry.
130
+ def export_mko_bundle(output_paths)
131
+ require "metanorma/document"
132
+ require "metanorma/mko"
133
+ # :xml is the freshly written semantic XML; orig_filename is the
134
+ # adoc SOURCE and is only right when an output_dir kept the
135
+ # semantic XML at the input location.
136
+ semantic_path = [output_paths[:xml], output_paths[:orig_filename]]
137
+ .find { |p1| p1 && File.exist?(p1) && File.extname(p1) != ".adoc" }
138
+ presentation = if File.exist?(output_paths[:presentationxml])
139
+ File.read(output_paths[:presentationxml])
140
+ end
141
+ Metanorma::Mko.export(File.read(semantic_path),
142
+ to: File.dirname(output_paths[:out]),
143
+ presentation_xml: presentation)
144
+ rescue LoadError => e
145
+ @log.add_msg("MKO_OUTPUT" => { category: "MKO Output",
146
+ error: "the mko output format requires " \
147
+ "the metanorma-document gem: %s",
148
+ severity: 0 })
149
+ @log.add("MKO_OUTPUT", nil, params: [e.message])
150
+ nil
151
+ end
152
+
123
153
  # Process format that requires presentation XML
124
154
  def process_via_presentation_xml(ext, output_paths, options, isodoc_options)
125
155
  @queue.schedule(ext, output_paths.dup, options.dup,
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.5.4".freeze
2
+ VERSION = "2.5.5".freeze
3
3
  end
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
4
+ version: 2.5.5
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-08-30 00:00:00.000000000 Z
11
+ date: 2026-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -223,6 +223,7 @@ files:
223
223
  - CHANGELOG.adoc
224
224
  - CODE_OF_CONDUCT.md
225
225
  - Gemfile
226
+ - Gemfile.devel
226
227
  - LICENSE.txt
227
228
  - README.adoc
228
229
  - lib/metanorma.rb