metanorma-standoc 2.8.3 → 2.8.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: 76c0e218fd82abc53141b42753ee4cbc14956ee9ccc75f1e8115bf91ac6a0eb6
4
- data.tar.gz: 532c96be450bb8f4a234ec5f6cd6c032d71fe89e20ad46e1f48195137b108c94
3
+ metadata.gz: 77911b09eea6861ff4b3614ba4de12829fd8955161d1aa8b8e917778ed9d3ac4
4
+ data.tar.gz: 11c749162a35a458a4cfa4c963a68a6e24f535c1fc4e943599966459612078ca
5
5
  SHA512:
6
- metadata.gz: bab6d097fc885f64299d90ceed88dc475c951ff7c916f176e504aaca63336b69e62bb12c48059004fe757200a448a15fd4c798ffcd2e7f9b7c04444259431799
7
- data.tar.gz: 6acb021a5f5348caa7c625db4d54a9a2af9e26e1720318cdd77a54c77bc0c734109c600d96a95d2a5a161bc5eb28f6db2336f06dee75bd896733fef8a600f1bf
6
+ metadata.gz: 24a4fb2005f50f620eaba63e869c86939066445938c74ea3c6df18c6b7a18f7d42cf1997b0ae50dd4adbe7d6bd03f2b4bec6270fb9f41676d4e94e97626160da
7
+ data.tar.gz: 5cb4f03fa198dd33054e7e81cbc8de074b8cd05a73cee3de4e68ec7e596db08ae17d46c2b1dd8837e2959789f9cfbf80c5ba00e1cc2709c30b26703a052eef3e
@@ -40,7 +40,6 @@ module Metanorma
40
40
  end
41
41
 
42
42
  def init_vars
43
- @log = Metanorma::Utils::Log.new # for error reporting downstream
44
43
  @fn_number ||= 0
45
44
  @refids = Set.new
46
45
  @anchor_alias = {}
@@ -179,7 +178,8 @@ module Metanorma
179
178
  end
180
179
 
181
180
  def clean_exit
182
- @novalid or @log.write("#{@output_dir}#{@filename}.err.html")
181
+ !@novalid && @local_log and
182
+ @log.write("#{@output_dir}#{@filename}.err.html")
183
183
  @files_to_delete.each { |f| FileUtils.rm f }
184
184
  end
185
185
 
@@ -21,6 +21,7 @@ module Metanorma
21
21
  # schema encapsulation of the document for validation
22
22
  class Converter
23
23
  Asciidoctor::Extensions.register do
24
+ preprocessor Metanorma::Standoc::ResolveIncludePreprocessor
24
25
  preprocessor Metanorma::Plugin::Lutaml::LutamlPreprocessor
25
26
  preprocessor Metanorma::Plugin::Lutaml::LutamlUmlAttributesTablePreprocessor
26
27
  preprocessor Metanorma::Plugin::Lutaml::LutamlUmlDatamodelDescriptionPreprocessor
@@ -100,6 +101,10 @@ module Metanorma
100
101
  outfilesuffix ".xml"
101
102
  @libdir = File.dirname(self.class::_file || __FILE__)
102
103
  @c = HTMLEntities.new
104
+ unless opts && @log = opts[:document]&.options&.dig(:log)
105
+ @log = Metanorma::Utils::Log.new
106
+ @local_log = true
107
+ end
103
108
  end
104
109
 
105
110
  class << self
@@ -2,14 +2,37 @@ require "pathname"
2
2
 
3
3
  module Asciidoctor
4
4
  class PreprocessorNoIfdefsReader < PreprocessorReader
5
- def preprocess_conditional_directive(keyword, target, delimiter, text)
5
+ private
6
+
7
+ def preprocess_conditional_directive(_keyword, _target, _delimiter, _text)
6
8
  false # decline to resolve idefs
7
9
  end
10
+
11
+ def resolve_include_path(expanded_target, attrlist, parsed_attrs)
12
+ inc_path, target_type, relpath = super
13
+ if inc_path && !%i(file uri).include?(target_type)
14
+ # include has been skipped because of error
15
+ n = peek_line(true)
16
+ /^Unresolved directive in/.match?(n) and
17
+ @document.converter.log
18
+ &.add("Include", nil,
19
+ HTMLEntities.new.encode(n, :basic), severity: 0)
20
+ end
21
+ [inc_path, target_type, relpath]
22
+ end
8
23
  end
9
24
  end
10
25
 
11
26
  module Metanorma
12
27
  module Standoc
28
+ # resolve all includes before doing any further preprocessing
29
+ class ResolveIncludePreprocessor < Asciidoctor::Extensions::Preprocessor
30
+ def process(doc, reader)
31
+ r = ::Asciidoctor::PreprocessorNoIfdefsReader.new doc, reader.lines
32
+ ::Asciidoctor::PreprocessorNoIfdefsReader.new doc, r.readlines
33
+ end
34
+ end
35
+
13
36
  class EmbedIncludeProcessor < Asciidoctor::Extensions::Preprocessor
14
37
  def process(doc, reader)
15
38
  reader.eof? and return reader
@@ -44,12 +67,12 @@ module Metanorma
44
67
  reader = ::Asciidoctor::PreprocessorReader.new doc
45
68
  b = Pathname.new doc.base_dir
46
69
  ret.reverse.each do |l|
47
- if l[:file]
48
- new = Pathname.new(l[:path]).relative_path_from(b).to_s
49
- #reader.push_include l[:lines], new, l[:path]
50
- reader.unshift_lines l[:lines]
51
- else reader.unshift_lines l[:lines]
52
- end
70
+ # if l[:file]
71
+ # new = Pathname.new(l[:path]).relative_path_from(b).to_s
72
+ # reader.push_include l[:lines], new, l[:path]
73
+ reader.unshift_lines l[:lines]
74
+ # else reader.unshift_lines l[:lines]
75
+ # end
53
76
  end
54
77
  reader
55
78
  end
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.8.3".freeze
22
+ VERSION = "2.8.4".freeze
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.3
4
+ version: 2.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.