metanorma 2.1.10 → 2.2.1

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: b8d17619f5a369f5df52db09ddae40490b5ceb22cd3932e22b8fa382d3bd078d
4
- data.tar.gz: b4ecb80e39e4d282b0d1a6ccb6523aeb519b2431211de5510f4fad81f09db04e
3
+ metadata.gz: 5d66c44fc8123332b449ee23540a8e0d009aa19b5a34f408bca97375f85223b0
4
+ data.tar.gz: 0227a49a94646c2bd0197fb5d49eabc237a6eb51350809a3f8436c601f41d41c
5
5
  SHA512:
6
- metadata.gz: 8b8fd5e20992cd0508fbcdb96ce7e4c0b2fca460a9ae1f8b7231ed2e43a4e15f3536fd30b7b717d1c3a00a8065e0064749eff22726c7100aae26301f606a7b69
7
- data.tar.gz: 476bd02101c3f23e99b6c414f839e442351adf137ddc2e922c6ae822ea95e7d6f5c66f98f062bfe51299d9ffb28a00f81dd8fefce5f42ac4ba94c39ac8755c32
6
+ metadata.gz: 503d2edd8d015e341949ab4de920abb7668bc1b13fb7d97697026fddad1ab11d9f94138257cffdd3b57ac32873d606cbe05689bcf8b9e8f7fb3baa19289a7d76
7
+ data.tar.gz: 41ba35a1a2ad8d740c9b7e3409f0297665c1746e3e461d2b26e2b203d66b09e26fc6bc9f1afebbe26134806a699ac8aa36350d28548629a08a2ae036aa3aa0e3
@@ -6,16 +6,37 @@ module Metanorma
6
6
  module Converters
7
7
  def bibdata_from_yaml(model, value)
8
8
  value and !value.empty? or return
9
+ force_primary_docidentifier_yaml(value)
9
10
  model.bibdata = Relaton::Cli::YAMLConvertor.convert_single_file(value)
10
11
  end
11
12
 
13
+ def force_primary_docidentifier_yaml(value)
14
+ case value["docid"]
15
+ when Array
16
+ value["docid"].empty? ||
17
+ value["docid"].none? do |x|
18
+ x["primary"] == "true"
19
+ end or
20
+ value["docid"].first["primary"] = "true"
21
+ when Hash
22
+ value["docid"]["primary"] ||= "true"
23
+ end
24
+ end
25
+
12
26
  def bibdata_to_yaml(model, doc)
13
27
  doc["bibdata"] = model.bibdata&.to_hash
14
28
  end
15
29
 
16
30
  def bibdata_from_xml(model, node)
17
- node and
18
- model.bibdata = Relaton::Cli.parse_xml(node.adapter_node)
31
+ node or return
32
+ force_primary_docidentifier_xml(node.adapter_node)
33
+ model.bibdata = Relaton::Cli.parse_xml(node.adapter_node)
34
+ end
35
+
36
+ def force_primary_docidentifier_xml(node)
37
+ node.at("//docidentifier[@primary = 'true']") and return node
38
+ d = node.at("//docidentifier") or return node
39
+ d["primary"] = "true"
19
40
  end
20
41
 
21
42
  def bibdata_to_xml(model, parent, doc)
@@ -11,14 +11,12 @@ module Metanorma
11
11
  end
12
12
 
13
13
  def svgmap_resolve(docxml, docid, presxml)
14
- #require "debug"; binding.b
15
14
  ids = @files.get(docid, :ids)
16
15
  docxml = svg_unnest(svg_datauri(docxml, docid))
17
16
  isodoc = IsoDoc::PresentationXMLConvert.new({})
18
17
  isodoc.bibitem_lookup(docxml)
19
18
  tag = presxml ? "fmt-eref" : "eref"
20
19
  docxml.xpath(ns("//svgmap//#{tag}")).each do |e|
21
- #require "debug"; binding.b
22
20
  svgmap_resolve_eref(e, isodoc, docxml, ids, presxml)
23
21
  end
24
22
  docxml.xpath(ns("//svgmap/target")).each do |t| # undo Presentation XML: Vectory takes eref not fmt-eref
@@ -39,8 +39,6 @@ module Metanorma
39
39
  def add_suffix_to_attrs(doc, suffix, tag_name, attr_name, isodoc)
40
40
  (suffix.nil? || suffix.empty?) and return
41
41
  doc.xpath(isodoc.ns("//#{tag_name}[@#{attr_name}]")).each do |elem|
42
- #warn "#{tag_name} : #{elem.name}" if attr_name == "bibitemid"
43
- #require 'debug'; binding.b if attr_name == "bibitemid" && #!%w(eref fmt-eref link fmt-link).include?(elem.name)
44
42
  a = elem.attributes[attr_name].value
45
43
  /_#{suffix}$/.match?(a) or
46
44
  elem.attributes[attr_name].value = "#{a}_#{suffix}"
@@ -91,6 +89,8 @@ module Metanorma
91
89
  isodoc.i18n_init(lang, script, nil) # read in internationalisation
92
90
  # TODO locale?
93
91
  isodoc.metadata_init(lang, script, nil, isodoc.i18n)
92
+ isodoc.xref_init(lang, script, nil, isodoc.i18n, {})
93
+ isodoc.xrefs.klass.meta = isodoc.meta
94
94
  isodoc.info(xml, nil)
95
95
  isodoc
96
96
  end
@@ -6,6 +6,7 @@ require "htmlentities"
6
6
  require "yaml"
7
7
  require "fontist"
8
8
  require "fontist/manifest/install"
9
+ require "metanorma-taste"
9
10
  require_relative "writeable"
10
11
  require_relative "validator"
11
12
  require_relative "compile_options"
@@ -182,17 +183,11 @@ module Metanorma
182
183
  "#{attrs.join("\n")}\n\n#{rest}"
183
184
  end
184
185
 
185
- # TODO: to config
186
186
  def process_input_adoc_overrides(attrs, options)
187
- case options[:supplied_type]
188
- when :icc
189
- f = File.join(File.dirname(__FILE__), "assets", "icc-boilerplate.adoc")
190
- [":boilerplate-authority: #{f}",
191
- ":publisher: International Color Consortium",
192
- ":publisher_abbr: ICC"].each { |a| attrs << a }
193
- options[":boilerplate-authority:"] = f
194
- end
195
- attrs
187
+ @registry.tastes.available_tastes.include?(options[:supplied_type]) or
188
+ return
189
+ c = Metanorma::TasteRegister.get(options[:supplied_type])
190
+ c.process_input_adoc_overrides(attrs, options)
196
191
  end
197
192
 
198
193
  def process_input_adoc_includes(file, filename)
@@ -92,8 +92,7 @@ module Metanorma
92
92
 
93
93
  def get_isodoc_options(file, options, ext)
94
94
  ret = @processor.extract_options(file)
95
- dir = options[:filename].sub(%r(/[^/]+$), "/")
96
- ret[:i18nyaml] &&= File.join(dir, ret[:i18nyaml])
95
+ get_isodoc_i18nyaml(options, ret)
97
96
  copy_isodoc_options_attrs(options, ret)
98
97
  font_manifest_mn2pdf(options, ret, ext)
99
98
  ret[:output_formats]&.select! do |k, _|
@@ -103,6 +102,13 @@ module Metanorma
103
102
  ret
104
103
  end
105
104
 
105
+ def get_isodoc_i18nyaml(options, ret)
106
+ dir = File.dirname(options[:filename])
107
+ ret[:i18nyaml] or return
108
+ (Pathname.new ret[:i18nyaml]).absolute? or
109
+ ret[:i18nyaml] = File.join(dir, ret[:i18nyaml])
110
+ end
111
+
106
112
  def copy_isodoc_options_attrs(options, ret)
107
113
  ret[:datauriimage] = true if options[:datauriimage]
108
114
  ret[:sourcefilename] = options[:filename]
@@ -55,6 +55,7 @@ module Metanorma
55
55
  pdf-owner-password pdf-allow-copy-content pdf-allow-edit-content
56
56
  pdf-allow-assemble-document pdf-allow-edit-annotations
57
57
  pdf-allow-print pdf-allow-print-hq pdf-allow-fill-in-forms
58
+ pdf-stylesheet pdf-stylesheet-override
58
59
  fonts font-license-agreement pdf-allow-access-content
59
60
  pdf-encrypt-metadata iso-word-template document-scheme
60
61
  localize-number iso-word-bg-strip-color modspec-identifier-base)
@@ -1,6 +1,7 @@
1
1
  # Registry of all Metanorma types and entry points
2
2
 
3
3
  require "singleton"
4
+ require "metanorma-taste"
4
5
 
5
6
  class Error < StandardError
6
7
  end
@@ -9,13 +10,17 @@ module Metanorma
9
10
  class Registry
10
11
  include Singleton
11
12
 
12
- attr_reader :processors
13
+ attr_reader :processors, :tastes
13
14
 
14
15
  # TODO: make aliases configurable
15
16
  def initialize
16
17
  @processors = {}
17
- @aliases = { csd: :cc, m3d: :m3aawg, mpfd: :mpfa, csand: :csa,
18
- icc: :iso }
18
+ @tastes = Metanorma::TasteRegister.instance
19
+ tastealiases = @tastes.available_tastes.each_with_object({}) do |x, m|
20
+ m[x] = @tastes.taste_info(x)[:base_flavor]
21
+ end
22
+ @aliases = { csd: :cc, m3d: :m3aawg, mpfd: :mpfa, csand: :csa }
23
+ .merge tastealiases
19
24
  end
20
25
 
21
26
  def alias(flavour)
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.1.10".freeze
2
+ VERSION = "2.2.1".freeze
3
3
  end
data/metanorma.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_runtime_dependency "fontist", ">= 1.14.3"
30
30
  spec.add_runtime_dependency "htmlentities"
31
31
  spec.add_runtime_dependency "isodoc", ">= 3.0.0"
32
+ spec.add_runtime_dependency "metanorma-taste"
32
33
  spec.add_runtime_dependency "mn2pdf", "~> 2"
33
34
  spec.add_runtime_dependency "nokogiri"
34
35
 
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.1.10
4
+ version: 2.2.1
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-05-26 00:00:00.000000000 Z
11
+ date: 2025-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 3.0.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: metanorma-taste
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: mn2pdf
85
99
  requirement: !ruby/object:Gem::Requirement