metanorma 2.2.3 → 2.2.4

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: ab41d7fdd92143add890202f0e64c0c88216c7936e603a0efd7a41df02b833c3
4
- data.tar.gz: '09fc660fdf0eddeb88ee0094560113a2d05504767c0b6c220a63be6be7e80eea'
3
+ metadata.gz: b4efa4e511db71c9743419f1a8fa69e71f89ad55ba00a3c98f9786d95e53899a
4
+ data.tar.gz: e498bbfdc5b5a86f448acd94a85f1cb4b5660cd567daa8d9f216ebd47ef2e28e
5
5
  SHA512:
6
- metadata.gz: 82c0f8b50777b5cf34262690a6e860d189c5eecf4b5365375ef24872e847d8c04d4624731155407d89b86d3d6839ce0295b3c3c44d76a350139555ff3c8d47fa
7
- data.tar.gz: a7f8736e34eb0bc5ab76092ab9eeaae682f1058d52f634bc8d06f45cfa26982ef97813584430af5eb262317b6fdde7baf065c2c077645727f4a32dd569974479
6
+ metadata.gz: e3043c95ec435acae073b5023831cfc63c1557b1e87a6767ac169185c569f0534663bc7bc834d222a915bb8ba205c9763224207f6980299facdecc52bcf2e26b
7
+ data.tar.gz: 52541d4d6ba827aeeaf978b6c13e040c368386a10021881049d9144976304a3054a6fe4370da294220abe9d88577993b646e14e3fda8026b7b6e9d778e8fe9b4
@@ -4,7 +4,7 @@ module Metanorma
4
4
  # Resolves references to other files in the collection. Three routines:
5
5
  # 1. Eref to a document that has been split into multiple documents
6
6
  # (sectionsplit) are resolved to direct eref to the split document
7
- # 2. Indirect erefs to a file anchor in an unknwon file in the collection
7
+ # 2. Indirect erefs to a file anchor in an unknown file in the collection
8
8
  # (bibitem[@type = 'internal'] ) are resolved to direct eref to the
9
9
  # containing document
10
10
  # 3. Direct erefs to other files in collection
@@ -75,7 +75,7 @@ module Metanorma
75
75
  xref_prefix_key(x, key, indirect)
76
76
  x["bibitemid"] = x["target"]
77
77
  m[x["bibitemid"]] = true
78
- xref_to_internal_eref_anchor(x, key, bibitems,
78
+ xref_to_internal_eref_anchor(x, bibitems,
79
79
  xml.root["document_suffix"], presxml)
80
80
  end.keys
81
81
  end
@@ -87,8 +87,9 @@ module Metanorma
87
87
  [bibitems, indirect_bibitems]
88
88
  end
89
89
 
90
- def xref_to_internal_eref_anchor(xref, key, bibitems, document_suffix, presxml)
90
+ def xref_to_internal_eref_anchor(xref, bibitems, document_suffix, presxml)
91
91
  t = xref["target"]
92
+ key = xref["type"]
92
93
  if d = bibitems[t]&.at(ns("./docidentifier[@type = 'repository']"))
93
94
  m = %r{^([^/]+)}.match(d.text) and
94
95
  t.sub!(%r(#{m[0]}_), "")
@@ -62,6 +62,7 @@ module Metanorma
62
62
 
63
63
  # Step 3: Determine which output formats to generate
64
64
  extensions = get_extensions(options)
65
+ @extensions = extensions # Capture extensions for later access
65
66
  return nil unless extensions
66
67
 
67
68
  # Step 4: Extract information from Semantic XML if requested
@@ -184,8 +185,8 @@ module Metanorma
184
185
  end
185
186
 
186
187
  def process_input_adoc_overrides(attrs, options)
187
- Metanorma::TasteRegister.instance.available_tastes.include?(options[:supplied_type]) or
188
- return
188
+ Metanorma::TasteRegister.instance.available_tastes
189
+ .include?(options[:supplied_type]) or return
189
190
  c = Metanorma::TasteRegister.get(options[:supplied_type])
190
191
  c.process_input_adoc_overrides(attrs, options)
191
192
  end
@@ -203,9 +204,24 @@ module Metanorma
203
204
  file = read_file(filename)
204
205
  file = process_input_adoc_hdr(file, options)
205
206
  file = process_input_adoc_includes(file, filename)
207
+ update_options_after_preprocessing(file, options)
206
208
  [file, @processor.input_to_isodoc(file, filename, options)]
207
209
  end
208
210
 
211
+ # need to update options, for any content added;
212
+ # e.g. new attributes from Metanorma taste
213
+ def update_options_after_preprocessing(file, options)
214
+ new_options = {}
215
+ Tempfile.open(["tmp", ".adoc"], encoding: "UTF-8") do |f|
216
+ f.write(file)
217
+ f.close
218
+ new_options = extract_options(f, {})
219
+ end
220
+ new_options.compact!
221
+ new_options.delete(:filename)
222
+ options.merge!(new_options)
223
+ end
224
+
209
225
  def process_input_xml(filename, _options)
210
226
  Util.log("[metanorma] Processing: Metanorma XML input.", :info)
211
227
  # TODO NN: this is a hack -- we should provide/bridge the
@@ -216,5 +232,23 @@ module Metanorma
216
232
  def read_file(filename)
217
233
  File.read(filename, encoding: "utf-8").gsub("\r\n", "\n")
218
234
  end
235
+
236
+ # Returns a mapping of format types to file suffixes based on the
237
+ # extensions that were determined during compilation.
238
+ # This method is only available after compile() has been called and
239
+ # reached Step 3 where extensions are finalized.
240
+ #
241
+ # @return [Hash] mapping of format symbols to file extensions
242
+ # e.g., { html: "html", doc: "doc", pdf: "pdf" }
243
+ # @return [Hash] empty hash if extensions haven't been captured yet
244
+ def output_format_mapping
245
+ return {} unless @extensions && @processor
246
+
247
+ @extensions.each_with_object({}) do |ext, mapping|
248
+ if @processor.output_formats[ext]
249
+ mapping[ext] = @processor.output_formats[ext]
250
+ end
251
+ end
252
+ end
219
253
  end
220
254
  end
@@ -44,6 +44,7 @@ module Metanorma
44
44
  end
45
45
 
46
46
  def extract_dir_options(options, options_in_file, filename)
47
+ filename.is_a?(Tempfile) and return
47
48
  dir = filename.sub(%r(/[^/]+$), "/")
48
49
  options_in_file[:relaton] and
49
50
  options[:relaton] ||= File.join(dir,
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.2.3".freeze
2
+ VERSION = "2.2.4".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.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-08-04 00:00:00.000000000 Z
11
+ date: 2025-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor