metanorma 1.7.2 → 1.7.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: ed2498b7fc0b4cc2074f2393f839c27991e7efa26645c065b3e852eb09737107
4
- data.tar.gz: a34ad968c4d6b650f8fb499b4a0713203e8d3b5a2c0093148becafa596d6918d
3
+ metadata.gz: d3a50d8116aadebecaf6fbdcdc1b9ffaee19cb233bf38ad6ea2f7b6b1b320fa8
4
+ data.tar.gz: 67283cbe9df47b100e3b6598f08bb7a00e9be1602d3a6cc7d41ff3b527673556
5
5
  SHA512:
6
- metadata.gz: 331642735b2ff401ef306a3851a27f220a6177acf7ef33fdd7d4e13b78809ca192b491961b6c8433882a1b8a3c80bdd77de1f66a4234bad1658a70ee16ce9ced
7
- data.tar.gz: e51adcc4e9bfd4d6a7f3f63f624d2114e4a9fcf475a16ae53ff2e23ba49fe19d2af1ebf21a5856b00b9ddd5388b74817996d03aaa8242cb2b4969a6e19a40651
6
+ metadata.gz: 195226d8f70127bfe659d1a032824482ec02911ca8f7f1e9d0f75f14f5b319e90912300345a50c05422b6dd87fc5b0b1674b11f66471e06c8ff79c39a4ab3db3
7
+ data.tar.gz: 4fbf96851ca7857e83767abbb86c13cc9a28130b289543f82b9d30841d55298703149b82d48597c6d25acc8ea7a0667ff00a49784187f471d0f685c0598a2104
@@ -20,8 +20,9 @@ module Metanorma
20
20
  end
21
21
 
22
22
  def get_bibitem_docid(bib, identifier)
23
- # IDs for repo references are untyped by default
24
- docid = bib.at(ns("./docidentifier[not(@type)]")) ||
23
+ docid =
24
+ bib.at(ns("./docidentifier[@type = 'metanorma-collection']")) ||
25
+ bib.at(ns("./docidentifier[not(@type)]")) ||
25
26
  bib.at(ns("./docidentifier"))
26
27
  docid &&= docid_prefix(docid)
27
28
  if @files.get(docid) then docid
@@ -22,18 +22,31 @@ module Metanorma
22
22
  @errors = []
23
23
  @isodoc = IsoDoc::Convert.new({})
24
24
  @fontist_installed = false
25
+ @log = Metanorma::Utils::Log.new
25
26
  end
26
27
 
27
28
  def compile(filename, options = {})
28
- require_libraries(options)
29
- options = options_extract(filename, options)
30
- validate_options(options)
29
+ options_process(filename, options)
31
30
  @processor = @registry.find_processor(options[:type].to_sym)
32
31
  extensions = get_extensions(options) or return nil
33
32
  (file, isodoc = process_input(filename, options)) or return nil
34
33
  relaton_export(isodoc, options)
35
34
  extract(isodoc, options[:extract], options[:extract_type])
36
35
  process_exts(filename, extensions, file, isodoc, options)
36
+ clean_exit(options)
37
+ end
38
+
39
+ def options_process(filename, options)
40
+ require_libraries(options)
41
+ options = options_extract(filename, options)
42
+ validate_options(options)
43
+ @log.save_to(filename, options[:output_dir])
44
+ options[:log] = @log
45
+ end
46
+
47
+ def clean_exit(options)
48
+ options[:novalid] and return
49
+ @log.write
37
50
  end
38
51
 
39
52
  def process_input(filename, options)
@@ -30,29 +30,27 @@ module Metanorma
30
30
  options[:format] ||= :asciidoc
31
31
  options[:filename] = filename
32
32
  options[:fontlicenseagreement] ||= "no-install-fonts"
33
+ options[:novalid] = o[:novalid] if o[:novalid]
33
34
  options
34
35
  end
35
36
 
36
37
  def get_extensions(options)
37
- options[:extension_keys] ||=
38
- @processor.output_formats.reduce([]) { |memo, (k, _)| memo << k }
39
- extensions = extract_extensions(options)
40
- if !extensions.include?(:presentation) && extensions.any? do |e|
38
+ ext = extract_extensions(options)
39
+ !ext.include?(:presentation) && ext.any? do |e|
41
40
  @processor.use_presentation_xml(e)
42
- end
43
- extensions << :presentation
44
- end
45
- extensions
41
+ end and ext << :presentation
42
+ !ext.include?(:rxl) && options[:site_generate] and
43
+ ext << :rxl
44
+ ext
46
45
  end
47
46
 
48
47
  def extract_extensions(options)
48
+ options[:extension_keys] ||=
49
+ @processor.output_formats.reduce([]) { |memo, (k, _)| memo << k }
49
50
  options[:extension_keys].reduce([]) do |memo, e|
50
51
  if @processor.output_formats[e] then memo << e
51
52
  else
52
- message = "[metanorma] Error: #{e} format is not supported " \
53
- "for this standard."
54
- @errors << message
55
- Util.log(message, :error)
53
+ unsupported_format_error(e)
56
54
  memo
57
55
  end
58
56
  end
@@ -65,6 +63,13 @@ module Metanorma
65
63
 
66
64
  private
67
65
 
66
+ def unsupported_format_error(ext)
67
+ message = "[metanorma] Error: #{ext} format is not supported " \
68
+ "for this standard."
69
+ @errors << message
70
+ Util.log(message, :error)
71
+ end
72
+
68
73
  def get_isodoc_options(file, options, ext)
69
74
  ret = @processor.extract_options(file)
70
75
  copy_isodoc_options_attrs(options, ret)
@@ -38,6 +38,7 @@ module Metanorma
38
38
  end
39
39
 
40
40
  def one_doc_collection?
41
+ return false
41
42
  docs = 0
42
43
  @files.each_value do |v|
43
44
  v[:attachment] and next
@@ -5,11 +5,11 @@ module Metanorma
5
5
  class Asciidoc < Base
6
6
  def process(file, filename, type, options = {})
7
7
  require "asciidoctor"
8
- out_opts = {
9
- to_file: false, safe: :safe, backend: type, header_footer: true,
10
- attributes: ["nodoc", "stem", "docfile=#{filename}",
11
- "output_dir=#{options[:output_dir]}"]
12
- }
8
+ out_opts = { to_file: false, safe: :safe, backend: type,
9
+ header_footer: true, log: options[:log],
10
+ novalid: options[:novalid],
11
+ attributes: ["nodoc", "stem", "docfile=#{filename}",
12
+ "output_dir=#{options[:output_dir]}"] }
13
13
  unless asciidoctor_validate(file, filename, out_opts)
14
14
  warn "Cannot continue compiling Asciidoctor document"
15
15
  abort
@@ -24,7 +24,7 @@ module Metanorma
24
24
  $stderr = StringIO.new
25
25
  ::Asciidoctor.load(file, options)
26
26
  %r{(\n|^)asciidoctor: ERROR: ['"]?#{Regexp.escape(filename ||
27
- "<empty>")}['"]?: line \d+: include file not found: }
27
+ '<empty>')}['"]?: line \d+: include file not found: }
28
28
  .match($stderr.string) and err = $stderr.string
29
29
  ensure
30
30
  $stderr = previous_stderr
@@ -39,15 +39,16 @@ module Metanorma
39
39
  /\n:mn-output-extensions:\s+(?<extensions>[^\n]+)\n/ =~ headerextract
40
40
  /\n:mn-relaton-output-file:\s+(?<relaton>[^\n]+)\n/ =~ headerextract
41
41
  /\n(?<asciimath>:mn-keep-asciimath:[^\n]*)\n/ =~ headerextract
42
+ /\n(?<novalid>:novalid:[^\n]*)\n/ =~ headerextract
42
43
  asciimath = if defined?(asciimath)
43
- (!asciimath.nil? && asciimath != ":mn-keep-asciimath: false")
44
+ !asciimath.nil? && asciimath != ":mn-keep-asciimath: false"
44
45
  end
45
46
  asciimath = nil if asciimath == false
46
47
  {
47
48
  type: defined?(type) ? type&.strip : nil,
48
49
  extensions: defined?(extensions) ? extensions&.strip : nil,
49
50
  relaton: defined?(relaton) ? relaton&.strip : nil,
50
- asciimath: asciimath,
51
+ asciimath: asciimath, novalid: !novalid.nil? || nil
51
52
  }.compact
52
53
  end
53
54
 
@@ -206,7 +206,8 @@ module Metanorma
206
206
  output_folder: "#{ident}_collection",
207
207
  format: %i(html),
208
208
  coverpage: File.join(dir, "cover.html")).coverpage
209
- filename = one_doc_coll ? "#{ident}_index.html" : "index.html"
209
+ #filename = one_doc_coll ? "#{ident}_index.html" : "index.html"
210
+ filename = "#{ident}_index.html"
210
211
  FileUtils.mv "#{ident}_collection/index.html", File.join(dir, filename)
211
212
  FileUtils.rm_rf "#{ident}_collection"
212
213
  filename
@@ -40,7 +40,12 @@ module Metanorma
40
40
 
41
41
  def self.gather_bibitems(xml)
42
42
  xml.xpath("//xmlns:bibitem[@id]").each_with_object({}) do |b, m|
43
- m[b["id"]] = b
43
+ if m[b["id"]]
44
+ b.remove
45
+ next # we can't update duplicate bibitem, processing updates wrong one
46
+ else
47
+ m[b["id"]] = b
48
+ end
44
49
  end
45
50
  end
46
51
 
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.7.2".freeze
2
+ VERSION = "1.7.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: 1.7.2
4
+ version: 1.7.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: 2024-03-10 00:00:00.000000000 Z
11
+ date: 2024-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor