metanorma-standoc 2.8.6 → 2.8.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c85d5bbd7c078ea07217f9d0e4eac15edec02f1123a2d631774a7d95e194b5ea
|
4
|
+
data.tar.gz: 69c26ff7e359967646790c05e81ec9addc1641bd05bf9d1e9bd2e58f330ba24a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 616aac498897af730a4bd1198011b7bfb310782ca3d1ee940638f753a39c5ee8ef9b0d9d344199d089fef554c757b52dcc1bfafe9dee22b031cf22616bbd358a
|
7
|
+
data.tar.gz: 88b94f216dc5db91750d334f0555edcf7cef65f8b2c6b011ea6684317dd25817ee216ea9cf935a13f5299710042b996f6f46ea5a784e95d5e2b43760507009b4
|
@@ -19,14 +19,30 @@ module Metanorma
|
|
19
19
|
def asciimath2mathml_indiv(elem)
|
20
20
|
elem["type"] = "MathML"
|
21
21
|
expr = @c.decode(elem.text)
|
22
|
-
ret =
|
23
|
-
|
24
|
-
ret += "<asciimath>#{@c.encode(@c.decode(expr), :basic)}</asciimath>"
|
22
|
+
ret = asciimath_parse(expr, elem)
|
23
|
+
ret += "<asciimath>#{@c.encode(expr, :basic)}</asciimath>"
|
25
24
|
elem.children = ret
|
26
25
|
rescue StandardError => e
|
27
26
|
asciimath2mathml_err(elem.to_xml, e)
|
28
27
|
end
|
29
28
|
|
29
|
+
# https://medium.com/@rickwang_wxc/in-ruby-given-a-string-detect-if-it-is-valid-numeric-c58275eace60
|
30
|
+
NUMERIC_REGEX = %r{^((\+|-)?\d*\.?\d+)([eE](\+|-){1}\d+)?$}.freeze
|
31
|
+
|
32
|
+
MATHML_NS = "http://www.w3.org/1998/Math/MathML".freeze
|
33
|
+
|
34
|
+
def asciimath_parse(expr, elem)
|
35
|
+
if NUMERIC_REGEX.match?(expr)
|
36
|
+
@novalid or elem["validate"] = "false"
|
37
|
+
<<~MATH
|
38
|
+
<math xmlns='#{MATHML_NS}'><mstyle displaystyle='false'><mn>#{expr}</mn></mstyle></math>
|
39
|
+
MATH
|
40
|
+
else
|
41
|
+
Plurimath::Math.parse(expr, "asciimath")
|
42
|
+
.to_mathml(display_style: elem["block"])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
30
46
|
def asciimath2mathml_err(text, expr)
|
31
47
|
err = "Malformed MathML: #{expr}\n#{text}"
|
32
48
|
@log.add("Maths", nil, err, severity: 0)
|
@@ -57,8 +73,6 @@ module Metanorma
|
|
57
73
|
xml.children = math
|
58
74
|
end
|
59
75
|
|
60
|
-
MATHML_NS = "http://www.w3.org/1998/Math/MathML".freeze
|
61
|
-
|
62
76
|
def mathml_preserve_space(math)
|
63
77
|
math.xpath(".//m:mtext", "m" => MATHML_NS).each do |x|
|
64
78
|
x.children = x.children.to_xml
|
@@ -193,7 +207,8 @@ module Metanorma
|
|
193
207
|
|
194
208
|
def mathml_cleanup(xmldoc)
|
195
209
|
unitsml = Asciimath2UnitsML::Conv.new(asciimath2unitsml_options)
|
196
|
-
xmldoc.xpath("//stem[@type = 'MathML']")
|
210
|
+
xmldoc.xpath("//stem[@type = 'MathML'][not(@validate = 'false')]")
|
211
|
+
.each do |x|
|
197
212
|
xml_unescape_mathml(x)
|
198
213
|
mathml_namespace(x)
|
199
214
|
mathml_preserve_space(x)
|
@@ -33,7 +33,7 @@ module Metanorma
|
|
33
33
|
@boilerplateauthority = node.attr("boilerplate-authority")
|
34
34
|
@embed_hdr = node.attr("embed_hdr")
|
35
35
|
@embed_id = node.attr("embed_id")
|
36
|
-
@document_scheme = node
|
36
|
+
@document_scheme = document_scheme(node)
|
37
37
|
@xrefstyle = node.attr("xrefstyle")
|
38
38
|
@source_linenums = node.attr("source-linenums-option") == "true"
|
39
39
|
end
|
@@ -100,7 +100,7 @@ module Metanorma
|
|
100
100
|
status[:midline_docattr] && !/^:[^ :]+: /.match?(text) and
|
101
101
|
status[:midline_docattr] = false
|
102
102
|
if (status[:is_delim] && /^(-+|\*+|=+|_+)$/.match?(text)) ||
|
103
|
-
(!status[:is_delim] && !status[:delimln] && text
|
103
|
+
(!status[:is_delim] && !status[:delimln] && /^-----*$|^\.\.\.\.\.*$/.match?(text))
|
104
104
|
status[:delimln] = text
|
105
105
|
status[:pass] = true
|
106
106
|
elsif status[:pass_delim]
|
@@ -34,8 +34,12 @@ module Metanorma
|
|
34
34
|
|
35
35
|
def math_validate(doc)
|
36
36
|
doc.xpath("//m:math", "m" => MATHML_NS).each do |m|
|
37
|
-
|
38
|
-
|
37
|
+
if m.parent["validate"] == "false"
|
38
|
+
m.parent.delete("validate")
|
39
|
+
else
|
40
|
+
math = mathml_sanitise(m.dup)
|
41
|
+
Plurimath::Math.parse(math, "mathml").to_mathml
|
42
|
+
end
|
39
43
|
rescue StandardError => e
|
40
44
|
math_validate_error(math, m, e)
|
41
45
|
end
|
data/metanorma-standoc.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
33
33
|
spec.add_dependency "crass", "~> 1.0.0"
|
34
34
|
spec.add_dependency "iev", "~> 0.3.0"
|
35
|
-
spec.add_dependency "isodoc", "~> 2.
|
35
|
+
spec.add_dependency "isodoc", "~> 2.10.0"
|
36
36
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
37
37
|
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.3.0"
|
38
38
|
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.0"
|
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
|
+
version: 2.8.7
|
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-
|
11
|
+
date: 2024-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
75
|
+
version: 2.10.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
82
|
+
version: 2.10.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: metanorma
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|