metanorma-standoc 2.8.4 → 2.8.5

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: 77911b09eea6861ff4b3614ba4de12829fd8955161d1aa8b8e917778ed9d3ac4
4
- data.tar.gz: 11c749162a35a458a4cfa4c963a68a6e24f535c1fc4e943599966459612078ca
3
+ metadata.gz: c543029f3b14b657d9688b9fd220df2a476c0d34a50eafd89bc7a94342a59fe0
4
+ data.tar.gz: 6c84b411e9fd00947893827f821a63f6877b3fab227873611fe76e6793776bf5
5
5
  SHA512:
6
- metadata.gz: 24a4fb2005f50f620eaba63e869c86939066445938c74ea3c6df18c6b7a18f7d42cf1997b0ae50dd4adbe7d6bd03f2b4bec6270fb9f41676d4e94e97626160da
7
- data.tar.gz: 5cb4f03fa198dd33054e7e81cbc8de074b8cd05a73cee3de4e68ec7e596db08ae17d46c2b1dd8837e2959789f9cfbf80c5ba00e1cc2709c30b26703a052eef3e
6
+ metadata.gz: eb65532e33f4114c5a268094f26053338b5dc56911f1801d3a78b4f61b6f1e9ed5d5689d2a6cf22a02d2c06266fb1758a809edf078c353933222c4fd64eba552
7
+ data.tar.gz: 9b2b1c7bd047da5dc81128e00f04da4b4f9e735699e542568665577167889ad9b671bad82fa72b4147f85a3263aa7a6e2923b1b444fe33f97e48f62c0bd9e0d8
@@ -8,6 +8,7 @@ require "fileutils"
8
8
  require "metanorma-utils"
9
9
  require_relative "render"
10
10
  require_relative "localbib"
11
+ require_relative "init"
11
12
  require "mn-requirements"
12
13
 
13
14
  module Metanorma
@@ -27,115 +28,6 @@ module Metanorma
27
28
  self.class::XML_NAMESPACE
28
29
  end
29
30
 
30
- def init(node)
31
- init_vars
32
- init_misc(node)
33
- init_processing(node)
34
- init_reqt(node)
35
- init_toc(node)
36
- init_output(node) # feeds init_biblio
37
- init_i18n(node)
38
- init_biblio(node)
39
- @metadata_attrs = metadata_attrs(node)
40
- end
41
-
42
- def init_vars
43
- @fn_number ||= 0
44
- @refids = Set.new
45
- @anchor_alias = {}
46
- @anchors = {}
47
- @internal_eref_namespaces = []
48
- @seen_headers = []
49
- @seen_headers_canonical = []
50
- @embed_hdr = []
51
- @reqt_model = nil
52
- @preface = true
53
- end
54
-
55
- def init_misc(node)
56
- @doctype = doctype(node)
57
- @draft = node.attributes.has_key?("draft")
58
- @index_terms = node.attr("index-terms")
59
- @boilerplateauthority = node.attr("boilerplate-authority")
60
- @embed_hdr = node.attr("embed_hdr")
61
- @embed_id = node.attr("embed_id")
62
- @document_scheme = node.attr("document-scheme")
63
- @xrefstyle = node.attr("xrefstyle")
64
- @source_linenums = node.attr("source-linenums-option") == "true"
65
- end
66
-
67
- def init_processing(node)
68
- @novalid = node.attr("novalid")
69
- @smartquotes = node.attr("smartquotes") != "false"
70
- @keepasciimath = node.attr("mn-keep-asciimath") &&
71
- node.attr("mn-keep-asciimath") != "false"
72
- @sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
73
- @sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
74
- @datauriimage = node.attr("data-uri-image") != "false"
75
- @blockunnumbered = (node.attr("block-unnumbered") || "").split(",")
76
- .map(&:strip)
77
- end
78
-
79
- def init_reqt(node)
80
- @default_requirement_model = node.attr("requirements-model") ||
81
- default_requirement_model
82
- @reqt_models = requirements_processor
83
- .new({ default: @default_requirement_model })
84
- end
85
-
86
- def init_toc(node)
87
- @htmltoclevels = node.attr("toclevels-html") ||
88
- node.attr("htmltoclevels") ||
89
- node.attr("toclevels") || toc_default[:html_levels]
90
- @doctoclevels = node.attr("toclevels-doc") ||
91
- node.attr("doctoclevels") || node.attr("toclevels") ||
92
- toc_default[:word_levels]
93
- @pdftoclevels = node.attr("toclevels-pdf") ||
94
- node.attr("toclevels") || toc_default[:pdf_levels]
95
- @toclevels = node.attr("toclevels") || toc_default[:html_levels]
96
- @tocfigures = node.attr("toc-figures")
97
- @toctables = node.attr("toc-tables")
98
- @tocrecommendations = node.attr("toc-recommendations")
99
- end
100
-
101
- def toc_default
102
- { word_levels: 2, html_levels: 2, pdf_levels: 2 }
103
- end
104
-
105
- def init_output(node)
106
- @fontheader = default_fonts(node)
107
- @files_to_delete = []
108
- @filename = if node.attr("docfile")
109
- File.basename(node.attr("docfile"))&.gsub(/\.adoc$/, "")
110
- else ""
111
- end
112
- @localdir = Metanorma::Utils::localdir(node)
113
- @output_dir = outputdir node
114
- end
115
-
116
- def init_i18n(node)
117
- @lang = node.attr("language") || "en"
118
- @script = node.attr("script") ||
119
- Metanorma::Utils.default_script(node.attr("language"))
120
- @locale = node.attr("locale")
121
- @isodoc = isodoc(@lang, @script, @locale, node.attr("i18nyaml"))
122
- @i18n = @isodoc.i18n
123
- end
124
-
125
- def init_biblio(node)
126
- @no_isobib_cache = node.attr("no-isobib-cache")
127
- @no_isobib = node.attr("no-isobib")
128
- @bibdb = nil
129
- init_bib_caches(node)
130
- init_iev_caches(node)
131
- @local_bibdb =
132
- ::Metanorma::Standoc::LocalBiblio.new(node, @localdir, self)
133
- end
134
-
135
- def requirements_processor
136
- Metanorma::Requirements
137
- end
138
-
139
31
  def document(node)
140
32
  ret = document1(node)
141
33
  clean_exit
@@ -233,7 +125,7 @@ module Metanorma
233
125
  end
234
126
 
235
127
  def metadata_attrs(node)
236
- node.attributes.each_with_object([]) do |(k, v), ret|
128
+ out = node.attributes.each_with_object([]) do |(k, v), ret|
237
129
  %w(presentation semantic).each do |t|
238
130
  /^#{t}-metadata-/.match?(k) or next
239
131
  k = k.sub(/^#{t}-metadata-/, "")
@@ -242,6 +134,17 @@ module Metanorma
242
134
  end
243
135
  end
244
136
  end.join
137
+ out + document_scheme_metadata(node)
138
+ end
139
+
140
+ def document_scheme_metadata(node)
141
+ a = document_scheme(node) or return ""
142
+ "<presentation-metadata><name>document-scheme</name>" \
143
+ "<value>#{a}</value></presentation-metadata>"
144
+ end
145
+
146
+ def document_scheme(node)
147
+ node.attr("document-scheme")
245
148
  end
246
149
 
247
150
  private
@@ -4,7 +4,6 @@ module Metanorma
4
4
  module Standoc
5
5
  module Cleanup
6
6
  def svgmap_cleanup(xmldoc)
7
- svg_uniqueids(xmldoc)
8
7
  svgmap_moveattrs(xmldoc)
9
8
  svgmap_populate(xmldoc)
10
9
  Vectory::SvgMapping.new(xmldoc, @localdir).call
@@ -82,7 +81,7 @@ module Metanorma
82
81
  types = MIME::Types.type_for(path) or return false
83
82
  types.first == "image/svg+xml" or return false
84
83
  svg = File.read(path, encoding: "utf-8") or return false
85
- img.replace(Nokogiri::XML(svg).root)
84
+ img.children = (Nokogiri::XML(svg).root)
86
85
  true
87
86
  end
88
87
 
@@ -76,9 +76,8 @@ module Metanorma
76
76
  def extract_localities_update_text(match)
77
77
  ret = match[:text]
78
78
  re = to_regex(LOCALITY_REGEX_VALUE_ONLY_STR)
79
- if re.match?(ret) && match[:punct] == ";"
79
+ re.match?(ret) && match[:punct] == ";" and
80
80
  ret.sub!(%r{^(#{CONN_REGEX_STR})}o, "\\1#{match[:locality]}=")
81
- end
82
81
  ret
83
82
  end
84
83
 
@@ -93,15 +92,13 @@ module Metanorma
93
92
  end
94
93
 
95
94
  def fill_in_eref_connectives(elem)
96
- return if elem.xpath("./localityStack").size < 2
97
-
95
+ elem.xpath("./localityStack").size < 2 and return
98
96
  elem.xpath("./localityStack[not(@connective)]").each do |l|
99
97
  n = l.next_element
100
98
  l["connective"] = if n && n.name == "localityStack" &&
101
99
  n["connective"] == "to"
102
100
  "from"
103
- else "and"
104
- end
101
+ else "and" end
105
102
  end
106
103
  end
107
104
 
@@ -193,9 +190,8 @@ module Metanorma
193
190
  def xref_parse_compound_locations(locations)
194
191
  l = locations.map { |y| y.split("!", 2) }
195
192
  l.map.with_index do |y, i|
196
- if y.size == 1
193
+ y.size == 1 and
197
194
  y.unshift(l.dig(i + 1, 0) == "to" ? "from" : "and")
198
- end
199
195
  y
200
196
  end
201
197
  end
@@ -209,8 +205,7 @@ module Metanorma
209
205
  def xref_cleanup1(xmldoc)
210
206
  xmldoc.xpath("//xref").each do |x|
211
207
  %r{:(?!//)}.match?(x["target"]) and xref_to_internal_eref(x)
212
- next unless x.name == "xref"
213
-
208
+ x.name == "xref" or next
214
209
  if refid? x["target"]
215
210
  xref_to_eref(x, "eref")
216
211
  elsif @anchor_alias[x["target"]] then xref_alias(x)
@@ -0,0 +1,114 @@
1
+ module Metanorma
2
+ module Standoc
3
+ module Base
4
+ def init(node)
5
+ init_vars
6
+ init_misc(node)
7
+ init_processing(node)
8
+ init_reqt(node)
9
+ init_toc(node)
10
+ init_output(node) # feeds init_biblio
11
+ init_i18n(node)
12
+ init_biblio(node)
13
+ @metadata_attrs = metadata_attrs(node)
14
+ end
15
+
16
+ def init_vars
17
+ @fn_number ||= 0
18
+ @refids = Set.new
19
+ @anchor_alias = {}
20
+ @anchors = {}
21
+ @internal_eref_namespaces = []
22
+ @seen_headers = []
23
+ @seen_headers_canonical = []
24
+ @embed_hdr = []
25
+ @reqt_model = nil
26
+ @preface = true
27
+ end
28
+
29
+ def init_misc(node)
30
+ @doctype = doctype(node)
31
+ @draft = node.attributes.has_key?("draft")
32
+ @index_terms = node.attr("index-terms")
33
+ @boilerplateauthority = node.attr("boilerplate-authority")
34
+ @embed_hdr = node.attr("embed_hdr")
35
+ @embed_id = node.attr("embed_id")
36
+ @document_scheme = node.attr("document-scheme")
37
+ @xrefstyle = node.attr("xrefstyle")
38
+ @source_linenums = node.attr("source-linenums-option") == "true"
39
+ end
40
+
41
+ def init_processing(node)
42
+ @novalid = node.attr("novalid")
43
+ @smartquotes = node.attr("smartquotes") != "false"
44
+ @keepasciimath = node.attr("mn-keep-asciimath") &&
45
+ node.attr("mn-keep-asciimath") != "false"
46
+ @sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
47
+ @sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
48
+ @datauriimage = node.attr("data-uri-image") != "false"
49
+ @blockunnumbered = (node.attr("block-unnumbered") || "").split(",")
50
+ .map(&:strip)
51
+ end
52
+
53
+ def init_reqt(node)
54
+ @default_requirement_model = node.attr("requirements-model") ||
55
+ default_requirement_model
56
+ @reqt_models = requirements_processor
57
+ .new({ default: @default_requirement_model })
58
+ end
59
+
60
+ def init_toc(node)
61
+ @htmltoclevels = node.attr("toclevels-html") ||
62
+ node.attr("htmltoclevels") ||
63
+ node.attr("toclevels") || toc_default[:html_levels]
64
+ @doctoclevels = node.attr("toclevels-doc") ||
65
+ node.attr("doctoclevels") || node.attr("toclevels") ||
66
+ toc_default[:word_levels]
67
+ @pdftoclevels = node.attr("toclevels-pdf") ||
68
+ node.attr("toclevels") || toc_default[:pdf_levels]
69
+ @toclevels = node.attr("toclevels") || toc_default[:html_levels]
70
+ @tocfigures = node.attr("toc-figures")
71
+ @toctables = node.attr("toc-tables")
72
+ @tocrecommendations = node.attr("toc-recommendations")
73
+ end
74
+
75
+ def toc_default
76
+ { word_levels: 2, html_levels: 2, pdf_levels: 2 }
77
+ end
78
+
79
+ def init_output(node)
80
+ @fontheader = default_fonts(node)
81
+ @files_to_delete = []
82
+ @filename = if node.attr("docfile")
83
+ File.basename(node.attr("docfile"))&.gsub(/\.adoc$/, "")
84
+ else ""
85
+ end
86
+ @localdir = Metanorma::Utils::localdir(node)
87
+ @output_dir = outputdir node
88
+ end
89
+
90
+ def init_i18n(node)
91
+ @lang = node.attr("language") || "en"
92
+ @script = node.attr("script") ||
93
+ Metanorma::Utils.default_script(node.attr("language"))
94
+ @locale = node.attr("locale")
95
+ @isodoc = isodoc(@lang, @script, @locale, node.attr("i18nyaml"))
96
+ @i18n = @isodoc.i18n
97
+ end
98
+
99
+ def init_biblio(node)
100
+ @no_isobib_cache = node.attr("no-isobib-cache")
101
+ @no_isobib = node.attr("no-isobib")
102
+ @bibdb = nil
103
+ init_bib_caches(node)
104
+ init_iev_caches(node)
105
+ @local_bibdb =
106
+ ::Metanorma::Standoc::LocalBiblio.new(node, @localdir, self)
107
+ end
108
+
109
+ def requirements_processor
110
+ Metanorma::Requirements
111
+ end
112
+ end
113
+ end
114
+ end
@@ -30,7 +30,7 @@ module Metanorma
30
30
  results = Plurimath::Math.parse(lxm_input, "latex")
31
31
  .to_mathml(display_style: block)
32
32
  if results.nil?
33
- @log.add("Math", nil,
33
+ @log.add("Maths", nil,
34
34
  "latexmlmath failed to process equation:\n#{lxm_input}",
35
35
  severity: 1)
36
36
  return
@@ -27,7 +27,7 @@ module Metanorma
27
27
  attrs.size > 1 && attrs.size < 5 and return true
28
28
  e = "invalid index \"#{target}\" cross-reference: wrong number of " \
29
29
  "attributes in `index:#{target}[#{attrs.values.join(',')}]`"
30
- parent.converter.log.add("Index", parent, e, severity: 0)
30
+ parent.converter.log.add("Crossreferences", parent, e, severity: 0)
31
31
  false
32
32
  end
33
33
 
@@ -213,8 +213,7 @@ module Metanorma
213
213
  end
214
214
 
215
215
  def init_bib_caches(node)
216
- return if @no_isobib
217
-
216
+ @no_isobib and return
218
217
  global = !@no_isobib_cache && !node.attr("local-cache-only")
219
218
  local = node.attr("local-cache") || node.attr("local-cache-only")
220
219
  local = nil if @no_isobib_cache
@@ -53,7 +53,7 @@ module Metanorma
53
53
  orig = ""
54
54
  a and orig += "\n\tAsciimath original: #{@c.decode(a.children.to_xml)}"
55
55
  l and orig += "\n\tLatexmath original: #{@c.decode(l.children.to_xml)}"
56
- @log.add("Mathematics", elem,
56
+ @log.add("Maths", elem,
57
57
  "Invalid MathML: #{math}\n #{error}#{orig}", severity: 0)
58
58
  end
59
59
 
@@ -83,7 +83,7 @@ module Metanorma
83
83
  outer.name == "figure" && inner.name == "figure" and return
84
84
  err =
85
85
  "There is an instance of #{inner.name} nested within #{outer.name}"
86
- @log.add("Syntax", inner, err)
86
+ @log.add("Style", inner, err)
87
87
  nested_asset_xref_report(outer, inner, doc)
88
88
  end
89
89
 
@@ -21,14 +21,14 @@ module Metanorma
21
21
  if callouts.size != annotations.size && !annotations.empty?
22
22
  err = "mismatch of callouts (#{callouts.size}) and annotations " \
23
23
  "(#{annotations.size})"
24
- @log.add("AsciiDoc Input", elem, err, severity: 0)
24
+ @log.add("Crossreferences", elem, err, severity: 0)
25
25
  end
26
26
  end
27
27
 
28
28
  def style_warning(node, msg, text = nil)
29
29
  w = msg
30
30
  w += ": #{text}" if text
31
- @log.add("Metanorma XML Style Warning", node, w)
31
+ @log.add("Style", node, w)
32
32
  end
33
33
 
34
34
  def asset_title_style(root)
@@ -61,7 +61,7 @@ module Metanorma
61
61
  docid = b.at("./docidentifier[@type = 'metanorma']") or next
62
62
  /^\[\d+\]$/.match?(docid.text) or next
63
63
  @log.add("Bibliography", b,
64
- "Numeric reference in normative references", severity: 0)
64
+ "Numeric reference in normative references", severity: 1)
65
65
  end
66
66
  end
67
67
  end
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.8.4".freeze
22
+ VERSION = "2.8.5".freeze
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.4
4
+ version: 2.8.5
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-04 00:00:00.000000000 Z
11
+ date: 2024-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -503,6 +503,7 @@ files:
503
503
  - lib/metanorma/standoc/front.rb
504
504
  - lib/metanorma/standoc/front_contributor.rb
505
505
  - lib/metanorma/standoc/front_organisation.rb
506
+ - lib/metanorma/standoc/init.rb
506
507
  - lib/metanorma/standoc/inline.rb
507
508
  - lib/metanorma/standoc/isodoc-compile.rng
508
509
  - lib/metanorma/standoc/isodoc.rng