plurimath 0.11.6 → 0.11.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 +4 -4
- data/lib/plurimath/asciimath/utility.rb +50 -0
- data/lib/plurimath/asciimath.rb +1 -0
- data/lib/plurimath/formatter/numbers/mathml_renderer.rb +15 -15
- data/lib/plurimath/formatter/numbers/omml_renderer.rb +19 -19
- data/lib/plurimath/html/utility.rb +18 -0
- data/lib/plurimath/html.rb +1 -0
- data/lib/plurimath/latex/utility.rb +118 -0
- data/lib/plurimath/latex.rb +1 -0
- data/lib/plurimath/math/core.rb +12 -12
- data/lib/plurimath/math/formula.rb +10 -10
- data/lib/plurimath/math/function/abs.rb +3 -3
- data/lib/plurimath/math/function/bar.rb +14 -14
- data/lib/plurimath/math/function/base.rb +15 -7
- data/lib/plurimath/math/function/binary_function.rb +7 -7
- data/lib/plurimath/math/function/cancel.rb +2 -2
- data/lib/plurimath/math/function/ceil.rb +1 -1
- data/lib/plurimath/math/function/color.rb +2 -2
- data/lib/plurimath/math/function/ddot.rb +3 -3
- data/lib/plurimath/math/function/dot.rb +8 -8
- data/lib/plurimath/math/function/fenced.rb +8 -8
- data/lib/plurimath/math/function/floor.rb +1 -1
- data/lib/plurimath/math/function/font_style/bold.rb +2 -2
- data/lib/plurimath/math/function/font_style/double_struck.rb +2 -2
- data/lib/plurimath/math/function/font_style/fraktur.rb +2 -2
- data/lib/plurimath/math/function/font_style/italic.rb +2 -2
- data/lib/plurimath/math/function/font_style/monospace.rb +2 -2
- data/lib/plurimath/math/function/font_style/normal.rb +2 -2
- data/lib/plurimath/math/function/font_style/sans-serif.rb +2 -2
- data/lib/plurimath/math/function/font_style/script.rb +2 -2
- data/lib/plurimath/math/function/font_style.rb +16 -15
- data/lib/plurimath/math/function/frac.rb +7 -7
- data/lib/plurimath/math/function/hat.rb +8 -8
- data/lib/plurimath/math/function/inf.rb +2 -2
- data/lib/plurimath/math/function/int.rb +8 -8
- data/lib/plurimath/math/function/left.rb +5 -5
- data/lib/plurimath/math/function/lim.rb +3 -3
- data/lib/plurimath/math/function/limits.rb +2 -2
- data/lib/plurimath/math/function/linebreak.rb +2 -2
- data/lib/plurimath/math/function/log.rb +10 -10
- data/lib/plurimath/math/function/longdiv.rb +1 -1
- data/lib/plurimath/math/function/menclose.rb +2 -2
- data/lib/plurimath/math/function/merror.rb +2 -2
- data/lib/plurimath/math/function/mod.rb +1 -1
- data/lib/plurimath/math/function/mpadded.rb +2 -2
- data/lib/plurimath/math/function/ms.rb +2 -2
- data/lib/plurimath/math/function/msgroup.rb +2 -2
- data/lib/plurimath/math/function/multiscript.rb +2 -2
- data/lib/plurimath/math/function/nary.rb +15 -15
- data/lib/plurimath/math/function/none.rb +1 -1
- data/lib/plurimath/math/function/norm.rb +1 -1
- data/lib/plurimath/math/function/obrace.rb +8 -8
- data/lib/plurimath/math/function/oint.rb +6 -6
- data/lib/plurimath/math/function/over.rb +5 -5
- data/lib/plurimath/math/function/overleftrightarrow.rb +7 -7
- data/lib/plurimath/math/function/overset.rb +5 -5
- data/lib/plurimath/math/function/phantom.rb +9 -9
- data/lib/plurimath/math/function/power.rb +5 -5
- data/lib/plurimath/math/function/power_base.rb +5 -5
- data/lib/plurimath/math/function/prod.rb +4 -4
- data/lib/plurimath/math/function/right.rb +5 -5
- data/lib/plurimath/math/function/root.rb +7 -7
- data/lib/plurimath/math/function/rule.rb +2 -2
- data/lib/plurimath/math/function/scarries.rb +1 -1
- data/lib/plurimath/math/function/semantics.rb +4 -4
- data/lib/plurimath/math/function/sqrt.rb +7 -7
- data/lib/plurimath/math/function/stackrel.rb +5 -5
- data/lib/plurimath/math/function/substack.rb +1 -1
- data/lib/plurimath/math/function/sum.rb +4 -4
- data/lib/plurimath/math/function/sup.rb +1 -1
- data/lib/plurimath/math/function/table/array.rb +1 -1
- data/lib/plurimath/math/function/table/bmatrix.rb +2 -2
- data/lib/plurimath/math/function/table/matrix.rb +2 -2
- data/lib/plurimath/math/function/table.rb +29 -29
- data/lib/plurimath/math/function/td.rb +3 -3
- data/lib/plurimath/math/function/ternary_function.rb +13 -13
- data/lib/plurimath/math/function/text.rb +4 -4
- data/lib/plurimath/math/function/tilde.rb +6 -6
- data/lib/plurimath/math/function/tr.rb +4 -4
- data/lib/plurimath/math/function/ubrace.rb +1 -1
- data/lib/plurimath/math/function/ul.rb +9 -9
- data/lib/plurimath/math/function/unary_function.rb +14 -14
- data/lib/plurimath/math/function/underover.rb +1 -1
- data/lib/plurimath/math/function/underset.rb +12 -12
- data/lib/plurimath/math/function/unitsml.rb +1 -1
- data/lib/plurimath/math/function/vec.rb +7 -7
- data/lib/plurimath/math/model_helper.rb +103 -0
- data/lib/plurimath/math/number.rb +2 -2
- data/lib/plurimath/math/symbols/symbol.rb +2 -2
- data/lib/plurimath/math/symbols/tilde.rb +1 -1
- data/lib/plurimath/math.rb +1 -0
- data/lib/plurimath/mathml/constants.rb +29 -155
- data/lib/plurimath/mathml/formula_transformation.rb +2 -5
- data/lib/plurimath/mathml/translator.rb +6 -0
- data/lib/plurimath/mathml/utility.rb +53 -0
- data/lib/plurimath/mathml.rb +1 -0
- data/lib/plurimath/omml/formula_transformation.rb +5 -5
- data/lib/plurimath/omml/translator.rb +8 -5
- data/lib/plurimath/omml/utility.rb +109 -0
- data/lib/plurimath/omml.rb +1 -0
- data/lib/plurimath/unicode_math/transform.rb +5 -1
- data/lib/plurimath/unicode_math/utility.rb +256 -0
- data/lib/plurimath/unicode_math.rb +1 -0
- data/lib/plurimath/utility/intent_encoding.rb +4 -4
- data/lib/plurimath/utility.rb +6 -815
- data/lib/plurimath/version.rb +1 -1
- data/lib/plurimath/xml_engine/oga/dumper.rb +8 -1
- data/lib/plurimath/xml_engine/ox_engine.rb +4 -1
- data/lib/plurimath/xml_helper.rb +47 -0
- data/lib/plurimath.rb +1 -0
- metadata +10 -2
data/lib/plurimath/version.rb
CHANGED
|
@@ -41,6 +41,7 @@ module Plurimath
|
|
|
41
41
|
ORD_GT = ">".ord
|
|
42
42
|
ORD_APOS = "'".ord
|
|
43
43
|
ORD_QUOT = '"'.ord
|
|
44
|
+
ORD_TAB = "\t".ord
|
|
44
45
|
ORD_NEWLINE = "\n".ord
|
|
45
46
|
ORD_CARRIAGERETURN = "\r".ord
|
|
46
47
|
|
|
@@ -56,8 +57,14 @@ module Plurimath
|
|
|
56
57
|
"""
|
|
57
58
|
elsif [ORD_NEWLINE, ORD_CARRIAGERETURN].include?(i)
|
|
58
59
|
i.chr("utf-8")
|
|
59
|
-
elsif i
|
|
60
|
+
elsif i == ORD_TAB
|
|
61
|
+
# Referenced rather than literal: a conforming parser normalises
|
|
62
|
+
# a literal tab in an attribute value to a space.
|
|
60
63
|
"&#x#{i.to_s(16).rjust(4, '0')};"
|
|
64
|
+
elsif i < 0x20
|
|
65
|
+
# XML 1.0 admits no other C0 control anywhere in a document, not
|
|
66
|
+
# even as a character reference, so there is nothing to emit.
|
|
67
|
+
""
|
|
61
68
|
else
|
|
62
69
|
i.chr("utf-8")
|
|
63
70
|
end
|
|
@@ -12,7 +12,10 @@ module Plurimath
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def dump(data, **options)
|
|
15
|
-
|
|
15
|
+
# XML 1.0 cannot represent C0 controls other than tab, newline and
|
|
16
|
+
# carriage return. Drop them rather than emit a document a conforming
|
|
17
|
+
# parser rejects; last wins, so a caller cannot reinstate them.
|
|
18
|
+
::Ox.dump(data.xml_nodes, **options, invalid_replace: "")
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
def load(data)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Plurimath
|
|
4
|
+
# XML element builders shared across every serializer (MathML and OMML),
|
|
5
|
+
# extracted from Plurimath::Utility (macro refactor). Sits alongside the
|
|
6
|
+
# Plurimath.xml_engine backend abstraction these methods build on.
|
|
7
|
+
class XmlHelper
|
|
8
|
+
class << self
|
|
9
|
+
def ox_element(node, attributes: [], namespace: "")
|
|
10
|
+
namespace = "#{namespace}:" unless namespace.empty?
|
|
11
|
+
|
|
12
|
+
element = Plurimath.xml_engine.new_element("#{namespace}#{node}")
|
|
13
|
+
element.set_attr(attributes)
|
|
14
|
+
element
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def rpr_element(wi_tag: false)
|
|
18
|
+
rpr_element = ox_element("rPr", namespace: "w")
|
|
19
|
+
attributes = { "w:ascii": "Cambria Math", "w:hAnsi": "Cambria Math" }
|
|
20
|
+
rpr_element << ox_element(
|
|
21
|
+
"rFonts",
|
|
22
|
+
namespace: "w",
|
|
23
|
+
attributes: attributes,
|
|
24
|
+
)
|
|
25
|
+
rpr_element << ox_element("i", namespace: "w") if wi_tag
|
|
26
|
+
rpr_element
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def update_nodes(element, nodes)
|
|
30
|
+
nodes&.each do |node|
|
|
31
|
+
next update_nodes(element, node) if node.is_a?(Array)
|
|
32
|
+
|
|
33
|
+
element << node unless node.nil?
|
|
34
|
+
end
|
|
35
|
+
element
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def pr_element(main_tag, wi_tag = false, namespace: "")
|
|
39
|
+
tag_name = "#{main_tag}Pr"
|
|
40
|
+
ox_element(
|
|
41
|
+
tag_name,
|
|
42
|
+
namespace: namespace,
|
|
43
|
+
) << rpr_element(wi_tag: wi_tag)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/lib/plurimath.rb
CHANGED
|
@@ -28,6 +28,7 @@ module Plurimath
|
|
|
28
28
|
autoload :Unitsml, "plurimath/unitsml"
|
|
29
29
|
autoload :Utility, "plurimath/utility"
|
|
30
30
|
autoload :XmlEngine, "plurimath/xml_engine"
|
|
31
|
+
autoload :XmlHelper, "plurimath/xml_helper"
|
|
31
32
|
autoload :Version, "plurimath/version"
|
|
32
33
|
|
|
33
34
|
def mml_adapter(adapter)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: plurimath
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.11.
|
|
4
|
+
version: 0.11.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bigdecimal
|
|
@@ -193,6 +193,7 @@ files:
|
|
|
193
193
|
- lib/plurimath/asciimath/parse.rb
|
|
194
194
|
- lib/plurimath/asciimath/parser.rb
|
|
195
195
|
- lib/plurimath/asciimath/transform.rb
|
|
196
|
+
- lib/plurimath/asciimath/utility.rb
|
|
196
197
|
- lib/plurimath/base_number_prefix.rb
|
|
197
198
|
- lib/plurimath/cli.rb
|
|
198
199
|
- lib/plurimath/configuration.rb
|
|
@@ -246,11 +247,13 @@ files:
|
|
|
246
247
|
- lib/plurimath/html/parser.rb
|
|
247
248
|
- lib/plurimath/html/transform.rb
|
|
248
249
|
- lib/plurimath/html/transform_utility.rb
|
|
250
|
+
- lib/plurimath/html/utility.rb
|
|
249
251
|
- lib/plurimath/latex.rb
|
|
250
252
|
- lib/plurimath/latex/constants.rb
|
|
251
253
|
- lib/plurimath/latex/parse.rb
|
|
252
254
|
- lib/plurimath/latex/parser.rb
|
|
253
255
|
- lib/plurimath/latex/transform.rb
|
|
256
|
+
- lib/plurimath/latex/utility.rb
|
|
254
257
|
- lib/plurimath/math.rb
|
|
255
258
|
- lib/plurimath/math/core.rb
|
|
256
259
|
- lib/plurimath/math/evaluation.rb
|
|
@@ -387,6 +390,7 @@ files:
|
|
|
387
390
|
- lib/plurimath/math/function/underset.rb
|
|
388
391
|
- lib/plurimath/math/function/unitsml.rb
|
|
389
392
|
- lib/plurimath/math/function/vec.rb
|
|
393
|
+
- lib/plurimath/math/model_helper.rb
|
|
390
394
|
- lib/plurimath/math/number.rb
|
|
391
395
|
- lib/plurimath/math/symbols.rb
|
|
392
396
|
- lib/plurimath/math/symbols/aa.rb
|
|
@@ -1855,11 +1859,13 @@ files:
|
|
|
1855
1859
|
- lib/plurimath/mathml/formula_transformation.rb
|
|
1856
1860
|
- lib/plurimath/mathml/parser.rb
|
|
1857
1861
|
- lib/plurimath/mathml/translator.rb
|
|
1862
|
+
- lib/plurimath/mathml/utility.rb
|
|
1858
1863
|
- lib/plurimath/number_formatter.rb
|
|
1859
1864
|
- lib/plurimath/omml.rb
|
|
1860
1865
|
- lib/plurimath/omml/formula_transformation.rb
|
|
1861
1866
|
- lib/plurimath/omml/parser.rb
|
|
1862
1867
|
- lib/plurimath/omml/translator.rb
|
|
1868
|
+
- lib/plurimath/omml/utility.rb
|
|
1863
1869
|
- lib/plurimath/setup/oga.rb
|
|
1864
1870
|
- lib/plurimath/setup/opal.rb.erb
|
|
1865
1871
|
- lib/plurimath/setup/ox_engine.rb
|
|
@@ -1875,6 +1881,7 @@ files:
|
|
|
1875
1881
|
- lib/plurimath/unicode_math/parsing_rules/masked.rb
|
|
1876
1882
|
- lib/plurimath/unicode_math/parsing_rules/sub_sup.rb
|
|
1877
1883
|
- lib/plurimath/unicode_math/transform.rb
|
|
1884
|
+
- lib/plurimath/unicode_math/utility.rb
|
|
1878
1885
|
- lib/plurimath/unitsml.rb
|
|
1879
1886
|
- lib/plurimath/utility.rb
|
|
1880
1887
|
- lib/plurimath/utility/intent_encoding.rb
|
|
@@ -1888,6 +1895,7 @@ files:
|
|
|
1888
1895
|
- lib/plurimath/xml_engine/oga/wrapper.rb
|
|
1889
1896
|
- lib/plurimath/xml_engine/ox_engine.rb
|
|
1890
1897
|
- lib/plurimath/xml_engine/ox_engine/element.rb
|
|
1898
|
+
- lib/plurimath/xml_helper.rb
|
|
1891
1899
|
- plurimath.gemspec
|
|
1892
1900
|
- supported_parens_list.adoc
|
|
1893
1901
|
- supported_symbols_list.adoc
|