metanorma 1.7.2 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed2498b7fc0b4cc2074f2393f839c27991e7efa26645c065b3e852eb09737107
4
- data.tar.gz: a34ad968c4d6b650f8fb499b4a0713203e8d3b5a2c0093148becafa596d6918d
3
+ metadata.gz: c5b5382892120774eb414751a3e9e3d196f73263e904566a3e2a30593480dbb1
4
+ data.tar.gz: 5e4fe2bac57854742838bdd57168dec395c5e8fd120f5d5b1b06e98ce2df8ad8
5
5
  SHA512:
6
- metadata.gz: 331642735b2ff401ef306a3851a27f220a6177acf7ef33fdd7d4e13b78809ca192b491961b6c8433882a1b8a3c80bdd77de1f66a4234bad1658a70ee16ce9ced
7
- data.tar.gz: e51adcc4e9bfd4d6a7f3f63f624d2114e4a9fcf475a16ae53ff2e23ba49fe19d2af1ebf21a5856b00b9ddd5388b74817996d03aaa8242cb2b4969a6e19a40651
6
+ metadata.gz: 31eca9aa8f63edb4be1feea653d288ac41c57c805253bc08af0d2b8686a5a85be136e29dbc4aeed179d89dd2c28714752713f6ed7c7b8e28478692e15c1f90bf
7
+ data.tar.gz: 2e84726aed63b99235576ea12ac5ba41cb05e943b0d70d5ebfec027529184e579b39f538bed63f058f83cdc6dda6a7dcb197d2f16b222d0e36825e71a1884797
@@ -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)
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.7.2".freeze
2
+ VERSION = "1.7.3".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.3
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-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor