metanorma-standoc 3.4.4 → 3.4.5
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 +4 -4
- data/lib/metanorma/cleanup/cleanup.rb +1 -2
- data/lib/metanorma/cleanup/index.rb +22 -0
- data/lib/metanorma/converter/inline.rb +2 -2
- data/lib/metanorma/converter/log.rb +3 -0
- data/lib/metanorma/converter/macros_nosub.rb +13 -3
- data/lib/metanorma/converter/terms.rb +13 -4
- data/lib/metanorma/standoc/version.rb +1 -1
- data/lib/metanorma/validate/validate.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aaf337d0f00fc3238db725b4dec6274ba4c68ef9122e1f7c75ff6cd3adf14b1a
|
|
4
|
+
data.tar.gz: 7d8a11d6b0cc974b5014fdcd06278c082d1c9d6bc69e0635a71010957c2a3eca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba837ca547627627915fe7e87e93d176c9a6cbc9d9352b6e3efd93cd8a85f6d7c68d7e66fccb187dcfe30348c4f675121268cb950fd62a654b1882cac0f211a7
|
|
7
|
+
data.tar.gz: d22ad092bcdc4593e8363ab65cdd254821358e4665670d359347f7d7b32ca114f56c1c6aeb7545f57794f255bf074ac92e277b77880fd7c842990d7d8ba4cea1
|
|
@@ -148,8 +148,7 @@ module Metanorma
|
|
|
148
148
|
sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup,
|
|
149
149
|
# floatingtitle_cleanup
|
|
150
150
|
obligations_cleanup(xmldoc)
|
|
151
|
-
|
|
152
|
-
block_index_cleanup(xmldoc)
|
|
151
|
+
index_cleanup(xmldoc)
|
|
153
152
|
key_cleanup(xmldoc) # feeds: table_cleanup, figure_cleanup,
|
|
154
153
|
# formula_cleanup
|
|
155
154
|
table_cleanup(xmldoc) # feeds: blocksource_cleanup
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
module Metanorma
|
|
2
2
|
module Standoc
|
|
3
3
|
module Index
|
|
4
|
+
EMPTY_INDEX_XPATH =
|
|
5
|
+
"//index[not(.//primary[normalize-space(text())]) " \
|
|
6
|
+
"or .//secondary[. and not(normalize-space(text()))] " \
|
|
7
|
+
"or .//tertiary[. and not(normalize-space(text()))]]".freeze
|
|
8
|
+
|
|
9
|
+
def index_cleanup(xmldoc)
|
|
10
|
+
para_index_cleanup(xmldoc)
|
|
11
|
+
block_index_cleanup(xmldoc)
|
|
12
|
+
index_empty_check(xmldoc)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def index_empty_check(xmldoc)
|
|
16
|
+
xmldoc.xpath(EMPTY_INDEX_XPATH).each do |i|
|
|
17
|
+
@log.add("STANDOC_64", i, params: [empty_index_context(i)])
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def empty_index_context(node)
|
|
22
|
+
ctx = node.ancestors.find { |a| a["id"] || a["anchor"] }
|
|
23
|
+
ctx ? (ctx["id"] || ctx["anchor"]) : "(unknown location)"
|
|
24
|
+
end
|
|
25
|
+
|
|
4
26
|
def block_index_cleanup(xmldoc)
|
|
5
27
|
xmldoc.xpath("//quote | //td | //th | //formula | //li | //dt | " \
|
|
6
28
|
"//dd | //example | //note | //figure | //sourcecode | " \
|
|
@@ -89,8 +89,8 @@ module Metanorma
|
|
|
89
89
|
when :emphasis then xml.em { |s| s << node.text }
|
|
90
90
|
when :strong then xml.strong { |s| s << node.text }
|
|
91
91
|
when :monospaced then xml.tt { |s| s << node.text }
|
|
92
|
-
when :double then xml << "
|
|
93
|
-
when :single then xml << "
|
|
92
|
+
when :double then xml << "“#{node.text}”"
|
|
93
|
+
when :single then xml << "‘#{node.text}’"
|
|
94
94
|
when :superscript then xml.sup { |s| s << node.text }
|
|
95
95
|
when :subscript then xml.sub { |s| s << node.text }
|
|
96
96
|
when :asciimath then stem_parse(node.text, xml, :asciimath, node)
|
|
@@ -195,6 +195,9 @@ module Metanorma
|
|
|
195
195
|
STANDOC_63: { category: "Images",
|
|
196
196
|
error: "Warning on PNG image: %s",
|
|
197
197
|
severity: 3 },
|
|
198
|
+
STANDOC_64: { category: "AsciiDoc Input",
|
|
199
|
+
error: "Empty index term: %s.",
|
|
200
|
+
severity: 0 },
|
|
198
201
|
RELATON_1: { category: "Relaton",
|
|
199
202
|
error: "(Error from Relaton) %s",
|
|
200
203
|
severity: 0 },
|
|
@@ -116,7 +116,7 @@ module Metanorma
|
|
|
116
116
|
p = Metanorma::Utils::LineStatus.new
|
|
117
117
|
lines = reader.lines.map do |t|
|
|
118
118
|
p.process(t)
|
|
119
|
-
!p.pass &&
|
|
119
|
+
!p.pass && /(?<!")`(?!")/.match?(t) ? inlinemonospace(t) : t
|
|
120
120
|
end
|
|
121
121
|
::Asciidoctor::PreprocessorReader.new document, lines
|
|
122
122
|
end
|
|
@@ -145,10 +145,20 @@ module Metanorma
|
|
|
145
145
|
# Regex to match single or double backticks with content
|
|
146
146
|
# Matches: `text` or ``text``
|
|
147
147
|
# Avoids: escaped backticks \`
|
|
148
|
-
|
|
148
|
+
# Avoids: the backticks of Asciidoc smart-quote markup "`...`", where a
|
|
149
|
+
# backtick abuts an enclosing " (the leading (?<![\\"]) and the (?!")
|
|
150
|
+
# guard). The (?!") guard is suppressed when the backtick run sits at a
|
|
151
|
+
# genuine monospace boundary (start, whitespace, or opening bracket), so
|
|
152
|
+
# monospace whose content itself begins with " — e.g. `"quote" A's` — is
|
|
153
|
+
# still protected from character replacements.
|
|
154
|
+
MonospaceRx = /
|
|
155
|
+
(?<![\\"]) (`{1,2})
|
|
156
|
+
(?: (?!") | (?<=[\s(\[{<]`) | (?<=[\s(\[{<]``) | (?<=\A`) | (?<=\A``) )
|
|
157
|
+
(.+?) (?<!\\) \1
|
|
158
|
+
/x
|
|
149
159
|
|
|
150
160
|
def inlinemonospace(text)
|
|
151
|
-
|
|
161
|
+
/(?<!")`(?!")/.match?(text) or return text
|
|
152
162
|
/^\[.*\]\s*$/.match?(text) and return text
|
|
153
163
|
pass_inline_split(text) do |x|
|
|
154
164
|
monospace_escape(x)
|
|
@@ -66,12 +66,21 @@ module Metanorma
|
|
|
66
66
|
@definitions = @stashed_definitions.pop
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
+
# dispatch on an explicit role override ([.nonterm], [.terms],
|
|
70
|
+
# [.boilerplate]); returns true if the role was handled
|
|
71
|
+
def term_def_subclause_role_parse(attrs, xml, node)
|
|
72
|
+
case node.role
|
|
73
|
+
when "nonterm" then nonterm_term_def_subclause_parse(attrs, xml, node)
|
|
74
|
+
when "terms" then term_def_parse(attrs, xml, node, false)
|
|
75
|
+
when "boilerplate" then terms_boilerplate_parse(attrs, xml, node)
|
|
76
|
+
else return false
|
|
77
|
+
end
|
|
78
|
+
true
|
|
79
|
+
end
|
|
80
|
+
|
|
69
81
|
# subclause contains subclauses
|
|
70
82
|
def term_def_subclause_parse(attrs, xml, node)
|
|
71
|
-
|
|
72
|
-
return nonterm_term_def_subclause_parse(attrs, xml, node)
|
|
73
|
-
node.role == "boilerplate" and
|
|
74
|
-
return terms_boilerplate_parse(attrs, xml, node)
|
|
83
|
+
term_def_subclause_role_parse(attrs, xml, node) and return
|
|
75
84
|
@definitions and return symbols_parse(attrs, xml, node)
|
|
76
85
|
term_contains_subclauses(node) and
|
|
77
86
|
return term_def_parse(attrs, xml, node, false)
|
|
@@ -89,6 +89,7 @@ module Metanorma
|
|
|
89
89
|
def mathml_sanitise(math)
|
|
90
90
|
math.to_xml(encoding: "US-ASCII").gsub(/ xmlns=["'][^"']+["']/, "")
|
|
91
91
|
.gsub(%r{<[^:/>]+:}, "<").gsub(%r{</[^:/>]+:}, "</")
|
|
92
|
+
.gsub(/>\s*\n\s*</, "><") # strip pretty-print whitespace; see STANDOC_33
|
|
92
93
|
end
|
|
93
94
|
|
|
94
95
|
def math_validate_error(math, elem, error)
|
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: 3.4.
|
|
4
|
+
version: 3.4.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: 2026-
|
|
11
|
+
date: 2026-06-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|