plurimath 0.3.7 → 0.3.9
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/constants.rb +1 -1
- data/lib/plurimath/asciimath/transform.rb +17 -0
- data/lib/plurimath/latex/constants.rb +3 -5
- data/lib/plurimath/math/core.rb +14 -0
- data/lib/plurimath/math/formula.rb +19 -6
- data/lib/plurimath/math/function/binary_function.rb +14 -4
- data/lib/plurimath/math/function/cancel.rb +4 -0
- data/lib/plurimath/math/function/ceil.rb +7 -0
- data/lib/plurimath/math/function/color.rb +4 -0
- data/lib/plurimath/math/function/ddot.rb +4 -3
- data/lib/plurimath/math/function/deg.rb +4 -0
- data/lib/plurimath/math/function/det.rb +4 -0
- data/lib/plurimath/math/function/dim.rb +4 -0
- data/lib/plurimath/math/function/dot.rb +18 -0
- data/lib/plurimath/math/function/exp.rb +4 -0
- data/lib/plurimath/math/function/floor.rb +8 -0
- data/lib/plurimath/math/function/font_style.rb +1 -3
- data/lib/plurimath/math/function/gcd.rb +4 -0
- data/lib/plurimath/math/function/glb.rb +4 -0
- data/lib/plurimath/math/function/hat.rb +13 -0
- data/lib/plurimath/math/function/hom.rb +3 -0
- data/lib/plurimath/math/function/inf.rb +18 -17
- data/lib/plurimath/math/function/int.rb +8 -8
- data/lib/plurimath/math/function/ker.rb +3 -0
- data/lib/plurimath/math/function/lcm.rb +3 -0
- data/lib/plurimath/math/function/lg.rb +4 -0
- data/lib/plurimath/math/function/lim.rb +1 -5
- data/lib/plurimath/math/function/liminf.rb +3 -0
- data/lib/plurimath/math/function/limsup.rb +3 -0
- data/lib/plurimath/math/function/ln.rb +4 -0
- data/lib/plurimath/math/function/longdiv.rb +3 -0
- data/lib/plurimath/math/function/lub.rb +4 -0
- data/lib/plurimath/math/function/max.rb +4 -0
- data/lib/plurimath/math/function/menclose.rb +1 -3
- data/lib/plurimath/math/function/merror.rb +1 -0
- data/lib/plurimath/math/function/min.rb +4 -0
- data/lib/plurimath/math/function/mod.rb +8 -0
- data/lib/plurimath/math/function/msline.rb +3 -0
- data/lib/plurimath/math/function/norm.rb +8 -0
- data/lib/plurimath/math/function/obrace.rb +29 -4
- data/lib/plurimath/math/function/oint.rb +55 -3
- data/lib/plurimath/math/function/over.rb +15 -1
- data/lib/plurimath/math/function/phantom.rb +7 -4
- data/lib/plurimath/math/function/power_base.rb +3 -1
- data/lib/plurimath/math/function/prod.rb +4 -0
- data/lib/plurimath/math/function/root.rb +2 -6
- data/lib/plurimath/math/function/scarries.rb +3 -0
- data/lib/plurimath/math/function/semantics.rb +4 -0
- data/lib/plurimath/math/function/sqrt.rb +1 -3
- data/lib/plurimath/math/function/stackrel.rb +15 -0
- data/lib/plurimath/math/function/substack.rb +45 -0
- data/lib/plurimath/math/function/sum.rb +8 -0
- data/lib/plurimath/math/function/sup.rb +4 -0
- data/lib/plurimath/math/function/table.rb +0 -4
- data/lib/plurimath/math/function/ternary_function.rb +13 -4
- data/lib/plurimath/math/function/tilde.rb +14 -0
- data/lib/plurimath/math/function/ubrace.rb +20 -0
- data/lib/plurimath/math/function/ul.rb +2 -0
- data/lib/plurimath/math/function/unary_function.rb +0 -4
- data/lib/plurimath/math/function/underover.rb +2 -5
- data/lib/plurimath/math/function/vec.rb +14 -0
- data/lib/plurimath/math/symbol.rb +8 -0
- data/lib/plurimath/math.rb +3 -1
- data/lib/plurimath/mathml/parser.rb +2 -2
- data/lib/plurimath/version.rb +1 -1
- metadata +2 -3
- data/lib/plurimath/math/function/underline.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d50026941bd556b94051c14a61a081ad96dbf839ed1aa324a9451382ef512e8
|
4
|
+
data.tar.gz: 40bf633bf5c0286daa011bf80d90baa2d522b18b9e545035d5dd6c32593792db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cf6f394801e567d2a7b482a14fc4da5e3b4c19515ce549a00fc9c247ce4d26c565dc5ff72586648cd30c51c0361f40808fb1117ed408bd9c319156622b34640
|
7
|
+
data.tar.gz: 65d1590db64f33f620ad438ae2d328eb1fe9a6bffeee9a427dba9f782bdc9b429ed5c54e9892ade8c59894ddd57d2bcc6680a4b7cb1b9cee26c67c0cab1b05d2
|
@@ -766,6 +766,18 @@ module Plurimath
|
|
766
766
|
)
|
767
767
|
end
|
768
768
|
|
769
|
+
rule(ternary_class: simple(:function),
|
770
|
+
base_value: simple(:base),
|
771
|
+
power_value: simple(:power),
|
772
|
+
third_value: sequence(:third)) do
|
773
|
+
third_value = third.is_a?(Slice) ? nil : third
|
774
|
+
Utility.get_class(function).new(
|
775
|
+
Utility.unfenced_value(base),
|
776
|
+
Utility.unfenced_value(power),
|
777
|
+
Utility.filter_values(third_value),
|
778
|
+
)
|
779
|
+
end
|
780
|
+
|
769
781
|
rule(unary_class: simple(:function),
|
770
782
|
intermediate_exp: simple(:int_exp)) do
|
771
783
|
first_value = if Utility::UNARY_CLASSES.include?(function)
|
@@ -821,6 +833,11 @@ module Plurimath
|
|
821
833
|
expr.insert(0, ternary)
|
822
834
|
end
|
823
835
|
|
836
|
+
rule(ternary: simple(:ternary),
|
837
|
+
left_right: simple(:left_right)) do
|
838
|
+
[ternary, left_right]
|
839
|
+
end
|
840
|
+
|
824
841
|
rule(unary_class: simple(:function),
|
825
842
|
text: simple(:text)) do
|
826
843
|
Utility.get_class(function).new(
|
@@ -1601,7 +1601,6 @@ module Plurimath
|
|
1601
1601
|
nmid: "∤",
|
1602
1602
|
land: "∧",
|
1603
1603
|
iint: "∬",
|
1604
|
-
oint: "∮",
|
1605
1604
|
nsim: "≁",
|
1606
1605
|
cong: "≅",
|
1607
1606
|
sdef: "≙",
|
@@ -1720,7 +1719,6 @@ module Plurimath
|
|
1720
1719
|
lor: "∨",
|
1721
1720
|
cap: "∩",
|
1722
1721
|
cup: "∪",
|
1723
|
-
int: "∫",
|
1724
1722
|
sim: "∼",
|
1725
1723
|
neq: "≠",
|
1726
1724
|
leq: "≤",
|
@@ -2524,7 +2522,7 @@ module Plurimath
|
|
2524
2522
|
rmoustache: :symbols,
|
2525
2523
|
sqrtbottom: :symbols,
|
2526
2524
|
underparen: :symbols,
|
2527
|
-
underbrace: :
|
2525
|
+
underbrace: :unary,
|
2528
2526
|
hrectangle: :symbols,
|
2529
2527
|
vrectangle: :symbols,
|
2530
2528
|
LEFTcircle: :symbols,
|
@@ -3455,7 +3453,7 @@ module Plurimath
|
|
3455
3453
|
nmid: :symbols,
|
3456
3454
|
land: :symbols,
|
3457
3455
|
iint: :symbols,
|
3458
|
-
oint: :
|
3456
|
+
oint: :ternary,
|
3459
3457
|
nsim: :symbols,
|
3460
3458
|
cong: :symbols,
|
3461
3459
|
sdef: :symbols,
|
@@ -3586,7 +3584,7 @@ module Plurimath
|
|
3586
3584
|
lor: :symbols,
|
3587
3585
|
cap: :symbols,
|
3588
3586
|
cup: :symbols,
|
3589
|
-
int: :
|
3587
|
+
int: :ternary,
|
3590
3588
|
sim: :symbols,
|
3591
3589
|
neq: :symbols,
|
3592
3590
|
leq: :symbols,
|
data/lib/plurimath/math/core.rb
CHANGED
@@ -15,6 +15,10 @@ module Plurimath
|
|
15
15
|
"subsup"
|
16
16
|
end
|
17
17
|
|
18
|
+
def omml_tag_name
|
19
|
+
"subSup"
|
20
|
+
end
|
21
|
+
|
18
22
|
def nary_attr_value
|
19
23
|
""
|
20
24
|
end
|
@@ -38,6 +42,16 @@ module Plurimath
|
|
38
42
|
def validate_function_formula
|
39
43
|
true
|
40
44
|
end
|
45
|
+
|
46
|
+
def r_element(string, rpr_tag: true)
|
47
|
+
r_tag = Utility.ox_element("r", namespace: "m")
|
48
|
+
if rpr_tag
|
49
|
+
sty_tag = Utility.ox_element("sty", namespace: "m", attributes: { "m:val": "p" })
|
50
|
+
r_tag << (Utility.ox_element("rPr", namespace: "m") << sty_tag)
|
51
|
+
end
|
52
|
+
r_tag << (Utility.ox_element("t", namespace: "m") << string)
|
53
|
+
Array(r_tag)
|
54
|
+
end
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
@@ -3,12 +3,13 @@
|
|
3
3
|
module Plurimath
|
4
4
|
module Math
|
5
5
|
class Formula < Core
|
6
|
-
attr_accessor :value, :left_right_wrapper, :displaystyle
|
6
|
+
attr_accessor :value, :left_right_wrapper, :displaystyle, :input_string
|
7
7
|
|
8
8
|
def initialize(
|
9
9
|
value = [],
|
10
10
|
left_right_wrapper = true,
|
11
|
-
displaystyle: true
|
11
|
+
displaystyle: true,
|
12
|
+
input_string: nil
|
12
13
|
)
|
13
14
|
@value = value.is_a?(Array) ? value : [value]
|
14
15
|
left_right_wrapper = false if @value.first.is_a?(Function::Left)
|
@@ -23,6 +24,8 @@ module Plurimath
|
|
23
24
|
|
24
25
|
def to_asciimath
|
25
26
|
value.map(&:to_asciimath).join(" ")
|
27
|
+
rescue
|
28
|
+
parse_error!(:asciimath)
|
26
29
|
end
|
27
30
|
|
28
31
|
def to_mathml(display_style: displaystyle)
|
@@ -36,6 +39,8 @@ module Plurimath
|
|
36
39
|
Utility.update_nodes(style, mathml_content)
|
37
40
|
Utility.update_nodes(math, [style])
|
38
41
|
Ox.dump(math, indent: 2).gsub("&", "&")
|
42
|
+
rescue
|
43
|
+
parse_error!(:mathml)
|
39
44
|
end
|
40
45
|
|
41
46
|
def to_mathml_without_math_tag
|
@@ -53,10 +58,14 @@ module Plurimath
|
|
53
58
|
|
54
59
|
def to_latex
|
55
60
|
value&.map(&:to_latex)&.join(" ")
|
61
|
+
rescue
|
62
|
+
parse_error!(:latex)
|
56
63
|
end
|
57
64
|
|
58
65
|
def to_html
|
59
66
|
value&.map(&:to_html)&.join(" ")
|
67
|
+
rescue
|
68
|
+
parse_error!(:html)
|
60
69
|
end
|
61
70
|
|
62
71
|
def omml_math_attrs
|
@@ -92,6 +101,8 @@ module Plurimath
|
|
92
101
|
Utility.update_nodes(math_element, omml_content)
|
93
102
|
Utility.update_nodes(para_element, Array(math_element))
|
94
103
|
Ox.dump(para_element, indent: 2).gsub("&", "&").lstrip
|
104
|
+
rescue
|
105
|
+
parse_error!(:omml)
|
95
106
|
end
|
96
107
|
|
97
108
|
def omml_content
|
@@ -115,10 +126,6 @@ module Plurimath
|
|
115
126
|
[nary_tag]
|
116
127
|
end
|
117
128
|
|
118
|
-
def class_name
|
119
|
-
self.class.name.split("::").last.downcase
|
120
|
-
end
|
121
|
-
|
122
129
|
def extract_class_from_text
|
123
130
|
return false unless (value.length < 2 && value&.first&.is_a?(Function::Text))
|
124
131
|
|
@@ -141,6 +148,12 @@ module Plurimath
|
|
141
148
|
def validate_function_formula
|
142
149
|
(value.none?(Function::Left) || value.none?(Function::Right))
|
143
150
|
end
|
151
|
+
|
152
|
+
protected
|
153
|
+
|
154
|
+
def parse_error!(type)
|
155
|
+
Math.parse_error!(input_string, type)
|
156
|
+
end
|
144
157
|
end
|
145
158
|
end
|
146
159
|
end
|
@@ -56,10 +56,6 @@ module Plurimath
|
|
56
56
|
[r_tag]
|
57
57
|
end
|
58
58
|
|
59
|
-
def class_name
|
60
|
-
self.class.name.split("::").last.downcase
|
61
|
-
end
|
62
|
-
|
63
59
|
protected
|
64
60
|
|
65
61
|
def latex_wrapped(field)
|
@@ -85,6 +81,20 @@ module Plurimath
|
|
85
81
|
r_tag << (Utility.ox_element("t", namespace: "m") << "​")
|
86
82
|
wrapper_tag << r_tag
|
87
83
|
end
|
84
|
+
|
85
|
+
def all_values_exist?
|
86
|
+
!(parameter_one.nil? && parameter_two.nil?)
|
87
|
+
end
|
88
|
+
|
89
|
+
def underover
|
90
|
+
return r_element(class_name, rpr_tag: false) unless all_values_exist?
|
91
|
+
|
92
|
+
first_value = Symbol.new(class_name)
|
93
|
+
overset = Overset.new(first_value, parameter_two)
|
94
|
+
return Array(overset.to_omml_without_math_tag) unless parameter_one
|
95
|
+
|
96
|
+
Array(Underset.new(overset, parameter_one)&.to_omml_without_math_tag)
|
97
|
+
end
|
88
98
|
end
|
89
99
|
end
|
90
100
|
end
|
@@ -19,6 +19,13 @@ module Plurimath
|
|
19
19
|
first_value << right_value,
|
20
20
|
)
|
21
21
|
end
|
22
|
+
|
23
|
+
def to_omml_without_math_tag
|
24
|
+
lceil = Symbol.new("⌈")
|
25
|
+
rceil = Symbol.new("⌉")
|
26
|
+
fenced = Fenced.new(lceil, Array(parameter_one), rceil)
|
27
|
+
Array(fenced.to_omml_without_math_tag)
|
28
|
+
end
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
@@ -18,11 +18,12 @@ module Plurimath
|
|
18
18
|
acc_tag = Utility.ox_element("acc", namespace: "m")
|
19
19
|
acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
|
20
20
|
acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val": ".." }))
|
21
|
-
me = Utility.ox_element("e", namespace: "m")
|
22
|
-
Utility.update_nodes(me, omml_value)
|
23
21
|
Utility.update_nodes(
|
24
22
|
acc_tag,
|
25
|
-
[
|
23
|
+
[
|
24
|
+
acc_pr_tag,
|
25
|
+
omml_parameter(parameter_one, tag_name: "e"),
|
26
|
+
],
|
26
27
|
)
|
27
28
|
[acc_tag]
|
28
29
|
end
|
@@ -18,6 +18,24 @@ module Plurimath
|
|
18
18
|
],
|
19
19
|
)
|
20
20
|
end
|
21
|
+
|
22
|
+
def to_omml_without_math_tag
|
23
|
+
acc_tag = Utility.ox_element("acc", namespace: "m")
|
24
|
+
acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
|
25
|
+
acc_pr_tag << Utility.ox_element(
|
26
|
+
"chr",
|
27
|
+
namespace: "m",
|
28
|
+
attributes: { "m:val": "." },
|
29
|
+
)
|
30
|
+
Utility.update_nodes(
|
31
|
+
acc_tag,
|
32
|
+
[
|
33
|
+
acc_pr_tag,
|
34
|
+
omml_parameter(parameter_one, tag_name: "e"),
|
35
|
+
],
|
36
|
+
)
|
37
|
+
[acc_tag]
|
38
|
+
end
|
21
39
|
end
|
22
40
|
end
|
23
41
|
end
|
@@ -22,6 +22,19 @@ module Plurimath
|
|
22
22
|
def validate_function_formula
|
23
23
|
false
|
24
24
|
end
|
25
|
+
|
26
|
+
def to_omml_without_math_tag
|
27
|
+
acc_tag = Utility.ox_element("acc", namespace: "m")
|
28
|
+
acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
|
29
|
+
acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val": "̂" }))
|
30
|
+
me = Utility.ox_element("e", namespace: "m")
|
31
|
+
Utility.update_nodes(me, omml_value)
|
32
|
+
Utility.update_nodes(
|
33
|
+
acc_tag,
|
34
|
+
[acc_pr_tag, me],
|
35
|
+
)
|
36
|
+
[acc_tag]
|
37
|
+
end
|
25
38
|
end
|
26
39
|
end
|
27
40
|
end
|
@@ -14,23 +14,24 @@ module Plurimath
|
|
14
14
|
|
15
15
|
def to_mathml_without_math_tag
|
16
16
|
first_value = Utility.ox_element("mo") << class_name
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
17
|
+
return first_value unless all_values_exist?
|
18
|
+
|
19
|
+
value_array = [first_value]
|
20
|
+
value_array << parameter_one&.to_mathml_without_math_tag
|
21
|
+
value_array << parameter_two&.to_mathml_without_math_tag
|
22
|
+
tag_name = if parameter_two && parameter_one
|
23
|
+
"underover"
|
24
|
+
else
|
25
|
+
parameter_one ? "under" : "over"
|
26
|
+
end
|
27
|
+
Utility.update_nodes(
|
28
|
+
Utility.ox_element("m#{tag_name}"),
|
29
|
+
value_array,
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_omml_without_math_tag
|
34
|
+
underover
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
@@ -13,22 +13,22 @@ module Plurimath
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_latex
|
16
|
-
first_value = "_#{
|
17
|
-
second_value = "
|
16
|
+
first_value = "_{#{parameter_one.to_latex}}" if parameter_one
|
17
|
+
second_value = "^{#{parameter_two.to_latex}}" if parameter_two
|
18
18
|
"\\#{class_name}#{first_value}#{second_value} #{parameter_three&.to_latex}".strip
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_mathml_without_math_tag
|
22
|
+
base_element = (Utility.ox_element("mo") << invert_unicode_symbols.to_s)
|
23
|
+
return base_element unless all_values_exist?
|
24
|
+
|
22
25
|
msubsup_tag = Utility.ox_element("msubsup")
|
23
|
-
mo_tag = Utility.ox_element("mo") << invert_unicode_symbols.to_s
|
24
|
-
first_value = parameter_one&.to_mathml_without_math_tag if parameter_one
|
25
|
-
second_value = parameter_two&.to_mathml_without_math_tag if parameter_two
|
26
26
|
Utility.update_nodes(
|
27
27
|
msubsup_tag,
|
28
28
|
[
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
base_element,
|
30
|
+
validate_mathml_tag(parameter_one),
|
31
|
+
validate_mathml_tag(parameter_two),
|
32
32
|
],
|
33
33
|
)
|
34
34
|
return msubsup_tag if parameter_three.nil?
|
@@ -40,11 +40,7 @@ module Plurimath
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def to_omml_without_math_tag
|
43
|
-
|
44
|
-
overset = Overset.new(lim, parameter_two)
|
45
|
-
return overset unless parameter_one
|
46
|
-
|
47
|
-
Underset.new(overset, parameter_one)&.to_omml_without_math_tag
|
43
|
+
underover
|
48
44
|
end
|
49
45
|
end
|
50
46
|
end
|
@@ -30,13 +30,11 @@ module Plurimath
|
|
30
30
|
borderbox = Utility.ox_element("borderBox", namespace: "m")
|
31
31
|
borderpr = Utility.ox_element("borderBoxPr", namespace: "m")
|
32
32
|
borderpr << Utility.pr_element("ctrl", true, namespace: "m")
|
33
|
-
me = Utility.ox_element("e", namespace: "m")
|
34
|
-
Utility.update_nodes(me, Array(parameter_two.to_omml_without_math_tag)) if parameter_two
|
35
33
|
Utility.update_nodes(
|
36
34
|
borderbox,
|
37
35
|
[
|
38
36
|
borderpr,
|
39
|
-
|
37
|
+
omml_parameter(parameter_two, tag_name: "e"),
|
40
38
|
],
|
41
39
|
)
|
42
40
|
[borderbox]
|