metanorma-standoc 2.9.6 → 2.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/html/htmlstyle.css +4 -1
- data/lib/metanorma/standoc/basicdoc.rng +861 -481
- data/lib/metanorma/standoc/biblio-standoc.rng +87 -20
- data/lib/metanorma/standoc/biblio.rng +882 -325
- data/lib/metanorma/standoc/cleanup_maths.rb +11 -10
- data/lib/metanorma/standoc/cleanup_text.rb +9 -2
- data/lib/metanorma/standoc/converter.rb +2 -0
- data/lib/metanorma/standoc/init.rb +19 -6
- data/lib/metanorma/standoc/inline.rb +15 -7
- data/lib/metanorma/standoc/isodoc.rng +1031 -915
- data/lib/metanorma/standoc/macros_inline.rb +8 -6
- data/lib/metanorma/standoc/reqt.rng +94 -75
- data/lib/metanorma/standoc/utils.rb +2 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- metadata +2 -2
@@ -20,7 +20,7 @@ module Metanorma
|
|
20
20
|
def asciimath2mathml_indiv(elem)
|
21
21
|
elem["type"] = "MathML"
|
22
22
|
expr = @c.decode(elem.text)
|
23
|
-
ret = asciimath_parse(expr, elem)
|
23
|
+
ret = asciimath_parse(expr, elem)&.strip
|
24
24
|
ret += "<asciimath>#{@c.encode(expr, :basic)}</asciimath>"
|
25
25
|
elem.children = ret
|
26
26
|
rescue StandardError => e
|
@@ -102,7 +102,7 @@ module Metanorma
|
|
102
102
|
ins
|
103
103
|
end
|
104
104
|
|
105
|
-
def
|
105
|
+
def mathml_unitsml(xmldoc)
|
106
106
|
xmldoc.at(".//m:*", "m" => UNITSML_NS) or return
|
107
107
|
misc = add_misc_container(xmldoc)
|
108
108
|
unitsml = misc.add_child("<UnitsML xmlns='#{UNITSML_NS}'/>").first
|
@@ -131,7 +131,7 @@ module Metanorma
|
|
131
131
|
profile = mathml_mn_profile(m)
|
132
132
|
attr = profile.each_with_object([]) do |(k, v), acc|
|
133
133
|
v == "nil" and next
|
134
|
-
acc << "#{k}='#{v}'"
|
134
|
+
acc << "#{k}='#{@c.decode v}'"
|
135
135
|
end.join(",")
|
136
136
|
attr.empty? or m["data-metanorma-numberformat"] = attr
|
137
137
|
end
|
@@ -152,10 +152,10 @@ module Metanorma
|
|
152
152
|
f = mathml_stem_format_attr(stem) or return
|
153
153
|
attr = quoted_csv_split(f, ",").map do |x|
|
154
154
|
m = /^(.+?)=(.+)?$/.match(x) or next
|
155
|
-
"#{m[1]}='#{m[2]}'"
|
155
|
+
"#{m[1]}='#{@c.decode m[2]}'"
|
156
156
|
end.join(",")
|
157
157
|
stem.xpath(".//m:mn", "m" => MATHML_NS).each do |m|
|
158
|
-
m["data-metanorma-numberformat"] = attr
|
158
|
+
attr.empty? or m["data-metanorma-numberformat"] = attr
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
@@ -168,7 +168,7 @@ module Metanorma
|
|
168
168
|
f == "default" or return f
|
169
169
|
if @numberfmt_default.empty?
|
170
170
|
"notation='basic'"
|
171
|
-
else @numberfmt_default&.map { |k, v| "#{k}
|
171
|
+
else @numberfmt_default&.map { |k, v| "#{k}='#{v}'" }&.join(",")
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -179,15 +179,16 @@ module Metanorma
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def mathml_cleanup(xmldoc)
|
182
|
-
|
182
|
+
a2u = Asciimath2UnitsML::Conv.new(asciimath2unitsml_options)
|
183
183
|
xmldoc.xpath("//stem[@type = 'MathML'][not(@validate = 'false')]")
|
184
184
|
.each do |x|
|
185
185
|
mathml_xml_cleanup(x)
|
186
|
-
|
186
|
+
a2u.MathML2UnitsML(x)
|
187
187
|
mathml_mathvariant(x)
|
188
|
-
mathml_number_format(x)
|
189
188
|
end
|
190
|
-
|
189
|
+
xmldoc.xpath("//stem[@type = 'MathML']")
|
190
|
+
.each { |x| mathml_number_format(x) }
|
191
|
+
mathml_unitsml(xmldoc)
|
191
192
|
end
|
192
193
|
end
|
193
194
|
end
|
@@ -40,14 +40,21 @@ module Metanorma
|
|
40
40
|
def linebreak_cleanup_block(block)
|
41
41
|
block.each_with_index do |e, i|
|
42
42
|
e[:skip] and next
|
43
|
-
lines = e[
|
44
|
-
e[:last] or lines << block[i + 1][:text].lines.first # next token context
|
43
|
+
lines = lines_strip_textspan(e, block[i + 1])
|
45
44
|
out = Metanorma::Utils.line_sanitise(lines)
|
46
45
|
e[:last] or out.pop
|
47
46
|
e[:elem].replace(out.join)
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
50
|
+
def lines_strip_textspan(span, nextspan)
|
51
|
+
lines = span[:text].lines[0..-2].map(&:rstrip) <<
|
52
|
+
span[:text].lines[-1]&.sub(/\n$/, "")
|
53
|
+
# no final line rstrip: can be space linking to next line
|
54
|
+
span[:last] or lines << nextspan[:text].lines.first # next token context
|
55
|
+
lines
|
56
|
+
end
|
57
|
+
|
51
58
|
def gather_text_for_linebreak_cleanup(block)
|
52
59
|
x = block.xpath(".//text()").map do |e|
|
53
60
|
{ elem: e, text: e.text,
|
@@ -25,6 +25,7 @@ module Metanorma
|
|
25
25
|
preprocessor Metanorma::Plugin::Lutaml::LutamlPreprocessor
|
26
26
|
preprocessor Metanorma::Plugin::Lutaml::LutamlUmlAttributesTablePreprocessor
|
27
27
|
preprocessor Metanorma::Plugin::Lutaml::LutamlUmlDatamodelDescriptionPreprocessor
|
28
|
+
preprocessor Metanorma::Plugin::Lutaml::LutamlEaXmiPreprocessor
|
28
29
|
preprocessor Metanorma::Plugin::Lutaml::LutamlUmlClassPreprocessor
|
29
30
|
inline_macro Metanorma::Plugin::Lutaml::LutamlFigureInlineMacro
|
30
31
|
inline_macro Metanorma::Plugin::Lutaml::LutamlTableInlineMacro
|
@@ -33,6 +34,7 @@ module Metanorma
|
|
33
34
|
block Metanorma::Plugin::Lutaml::LutamlDiagramBlock
|
34
35
|
block_macro Metanorma::Plugin::Lutaml::LutamlGmlDictionaryBlockMacro
|
35
36
|
block Metanorma::Plugin::Lutaml::LutamlGmlDictionaryBlock
|
37
|
+
block_macro Metanorma::Plugin::Lutaml::LutamlKlassTableBlockMacro
|
36
38
|
preprocessor Metanorma::Standoc::EmbedIncludeProcessor
|
37
39
|
preprocessor Metanorma::Standoc::LinkProtectPreprocessor
|
38
40
|
preprocessor Metanorma::Standoc::Datamodel::AttributesTablePreprocessor
|
@@ -7,6 +7,8 @@ module Metanorma
|
|
7
7
|
init_vars
|
8
8
|
init_misc(node)
|
9
9
|
init_processing(node)
|
10
|
+
init_log(node)
|
11
|
+
init_image(node)
|
10
12
|
init_reqt(node)
|
11
13
|
init_toc(node)
|
12
14
|
init_output(node) # feeds init_biblio
|
@@ -47,11 +49,22 @@ module Metanorma
|
|
47
49
|
@smartquotes = node.attr("smartquotes") != "false"
|
48
50
|
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
49
51
|
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
52
|
+
@blockunnumbered = (node.attr("block-unnumbered") || "").split(",")
|
53
|
+
.map(&:strip)
|
54
|
+
end
|
55
|
+
|
56
|
+
def init_log(node)
|
57
|
+
@log or return
|
58
|
+
severity = node.attr("log-filter-severity")&.to_i || 4
|
59
|
+
category = node.attr("log-filter-category") || ""
|
60
|
+
category = category.split(",").map(&:strip)
|
61
|
+
@log.suppress_log = { severity:, category: }
|
62
|
+
end
|
63
|
+
|
64
|
+
def init_image(node)
|
50
65
|
@datauriimage = node.attr("data-uri-image") != "false"
|
51
66
|
@datauriattachment = node.attr("data-uri-attachment") != "false"
|
52
67
|
@dataurimaxsize = node.attr("data-uri-maxsize")&.to_i || 13981013
|
53
|
-
@blockunnumbered = (node.attr("block-unnumbered") || "").split(",")
|
54
|
-
.map(&:strip)
|
55
68
|
end
|
56
69
|
|
57
70
|
def init_reqt(node)
|
@@ -123,15 +136,15 @@ module Metanorma
|
|
123
136
|
def init_math(node)
|
124
137
|
@keepasciimath = node.attr("mn-keep-asciimath") &&
|
125
138
|
node.attr("mn-keep-asciimath") != "false"
|
126
|
-
@numberfmt_default = kv_parse(node.attr("number-presentation"))
|
127
|
-
@numberfmt_formula = node.attr("number-presentation-formula")
|
139
|
+
@numberfmt_default = kv_parse(@c.decode(node.attr("number-presentation")))
|
140
|
+
@numberfmt_formula = @c.decode(node.attr("number-presentation-formula"))
|
128
141
|
@numberfmt_formula == "number-presentation" and
|
129
|
-
@numberfmt_formula = node.attr("number-presentation")
|
142
|
+
@numberfmt_formula = @c.decode(node.attr("number-presentation"))
|
130
143
|
@numberfmt_formula == "default" and
|
131
144
|
@numberfmt_formula = "notation='basic'"
|
132
145
|
@numberfmt_prof = node.attributes.each_with_object({}) do |(k, v), m|
|
133
146
|
p = /^number-presentation-profile-(.*)$/.match(k) or next
|
134
|
-
m[p[1]] = kv_parse(v)
|
147
|
+
m[p[1]] = kv_parse(@c.decode(v))
|
135
148
|
end
|
136
149
|
end
|
137
150
|
|
@@ -40,21 +40,29 @@ module Metanorma
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def stem_parse(text, xml, style, node)
|
43
|
-
|
43
|
+
attrs, text = stem_attrs(node, text)
|
44
44
|
if /<([^:>&]+:)?math(\s+[^>&]+)?> |
|
45
45
|
<([^:>&]+:)?math(\s+[^>&]+)?>/x.match? text
|
46
|
-
xml.stem **
|
46
|
+
xml.stem **attrs.merge(type: "MathML") do |s|
|
47
47
|
s << xml_encode(text)
|
48
48
|
end
|
49
|
-
elsif style == :latexmath then latex_parse(text, xml,
|
49
|
+
elsif style == :latexmath then latex_parse(text, xml, attrs)
|
50
50
|
else
|
51
|
-
xml.stem text&.gsub("&#", "&#"), **
|
51
|
+
xml.stem text&.gsub("&#", "&#"), **attrs.merge(type: "AsciiMath")
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
STEM_ATTRS = "number-format".freeze
|
56
|
+
|
57
|
+
def stem_attrs(node, text)
|
58
|
+
attrs = STEM_ATTRS.split("|").each_with_object({}) do |k, m|
|
59
|
+
n = node.attr(k) and m[k.to_sym] = n
|
60
|
+
end
|
61
|
+
while m = /^(#{STEM_ATTRS})(=[^%]+)?%(.*)$/o.match(text)
|
62
|
+
text = m[3]
|
63
|
+
attrs[m[1].to_sym] = m[2]&.sub(/^=/, "")
|
64
|
+
end
|
65
|
+
[{ block: node.block? }.merge(attrs), text]
|
58
66
|
end
|
59
67
|
|
60
68
|
def latex_parse(text, xml, attr)
|