plurimath 0.3.6 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/plurimath/asciimath/constants.rb +1 -1
- data/lib/plurimath/latex/constants.rb +3 -5
- data/lib/plurimath/math/core.rb +10 -0
- data/lib/plurimath/math/formula.rb +9 -4
- data/lib/plurimath/math/function/binary_function.rb +4 -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 +24 -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 +3 -1
- 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 +56 -3
- data/lib/plurimath/math/function/over.rb +15 -1
- data/lib/plurimath/math/function/phantom.rb +7 -4
- 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/sup.rb +4 -0
- data/lib/plurimath/math/function/ternary_function.rb +6 -4
- data/lib/plurimath/math/function/tilde.rb +14 -0
- data/lib/plurimath/math/function/ubrace.rb +16 -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/vec.rb +14 -0
- data/lib/plurimath/mathml/parser.rb +4 -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: 78fffd236ecb53260b07fa02ce5cc2254d3835a6491229a7acc50c2a2ed80dbb
|
4
|
+
data.tar.gz: e17acb1342c8b5a7f5de3b8496962a12264404f9dd8902a42c47069a6ad0a157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a66739db5ef92081d8c73af2bbebaf77aa03bab5f8befbd14a9a80bdb4eea4d8c03e996dbc0aedbb5cf16c0bd90189a32dde1d67925c646f02cec6423e532f3c
|
7
|
+
data.tar.gz: 81e43972fead184a05ebc04948bba6433fef1ce6824223bd59b8a89d08c2ac41f4adbcb41e00426dd2d9dad6d6ff04a0ec2fc34ba7f51a7457f258b5087e0e72
|
@@ -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
@@ -38,6 +38,16 @@ module Plurimath
|
|
38
38
|
def validate_function_formula
|
39
39
|
true
|
40
40
|
end
|
41
|
+
|
42
|
+
def r_element(string, rpr_tag: true)
|
43
|
+
r_tag = Utility.ox_element("r", namespace: "m")
|
44
|
+
if rpr_tag
|
45
|
+
sty_tag = Utility.ox_element("sty", namespace: "m", attributes: { "m:val": "p" })
|
46
|
+
r_tag << (Utility.ox_element("rPr", namespace: "m") << sty_tag)
|
47
|
+
end
|
48
|
+
r_tag << (Utility.ox_element("t", namespace: "m") << string)
|
49
|
+
Array(r_tag)
|
50
|
+
end
|
41
51
|
end
|
42
52
|
end
|
43
53
|
end
|
@@ -3,12 +3,17 @@
|
|
3
3
|
module Plurimath
|
4
4
|
module Math
|
5
5
|
class Formula < Core
|
6
|
-
attr_accessor :value, :left_right_wrapper
|
6
|
+
attr_accessor :value, :left_right_wrapper, :displaystyle
|
7
7
|
|
8
|
-
def initialize(
|
8
|
+
def initialize(
|
9
|
+
value = [],
|
10
|
+
left_right_wrapper = true,
|
11
|
+
displaystyle: true
|
12
|
+
)
|
9
13
|
@value = value.is_a?(Array) ? value : [value]
|
10
14
|
left_right_wrapper = false if @value.first.is_a?(Function::Left)
|
11
15
|
@left_right_wrapper = left_right_wrapper
|
16
|
+
@displaystyle = displaystyle
|
12
17
|
end
|
13
18
|
|
14
19
|
def ==(object)
|
@@ -20,12 +25,12 @@ module Plurimath
|
|
20
25
|
value.map(&:to_asciimath).join(" ")
|
21
26
|
end
|
22
27
|
|
23
|
-
def to_mathml
|
28
|
+
def to_mathml(display_style: displaystyle)
|
24
29
|
math_attrs = {
|
25
30
|
xmlns: "http://www.w3.org/1998/Math/MathML",
|
26
31
|
display: "block",
|
27
32
|
}
|
28
|
-
style_attrs = { displaystyle:
|
33
|
+
style_attrs = { displaystyle: display_style }
|
29
34
|
math = Utility.ox_element("math", attributes: math_attrs)
|
30
35
|
style = Utility.ox_element("mstyle", attributes: style_attrs)
|
31
36
|
Utility.update_nodes(style, mathml_content)
|
@@ -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,10 @@ 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
88
|
end
|
89
89
|
end
|
90
90
|
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,30 @@ 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 if 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
|
+
return r_element("inf", rpr_tag: false) unless all_values_exist?
|
35
|
+
|
36
|
+
inf = Symbol.new("inf")
|
37
|
+
overset = Overset.new(inf, parameter_two)
|
38
|
+
return Array(overset.to_omml_without_math_tag) unless parameter_one
|
39
|
+
|
40
|
+
Array(Underset.new(overset, parameter_one)&.to_omml_without_math_tag)
|
34
41
|
end
|
35
42
|
end
|
36
43
|
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,9 +40,11 @@ module Plurimath
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def to_omml_without_math_tag
|
43
|
+
return r_element("lim", rpr_tag: false) unless all_values_exist?
|
44
|
+
|
43
45
|
lim = Symbol.new("lim")
|
44
46
|
overset = Overset.new(lim, parameter_two)
|
45
|
-
return overset unless parameter_one
|
47
|
+
return overset.to_omml_without_math_tag unless parameter_one
|
46
48
|
|
47
49
|
Underset.new(overset, parameter_one)&.to_omml_without_math_tag
|
48
50
|
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]
|
@@ -38,6 +38,14 @@ module Plurimath
|
|
38
38
|
second_value = "<i>#{parameter_two.to_html}</i>" if parameter_two
|
39
39
|
"#{first_value}<i>mod</i>#{second_value}"
|
40
40
|
end
|
41
|
+
|
42
|
+
def to_omml_without_math_tag
|
43
|
+
values = []
|
44
|
+
values << parameter_one.insert_t_tag if parameter_one
|
45
|
+
values << r_element("mod")
|
46
|
+
values << parameter_two.insert_t_tag if parameter_two
|
47
|
+
values
|
48
|
+
end
|
41
49
|
end
|
42
50
|
end
|
43
51
|
end
|
@@ -22,13 +22,38 @@ module Plurimath
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def tag_name
|
26
|
-
"underover"
|
27
|
-
end
|
28
|
-
|
29
25
|
def validate_function_formula
|
30
26
|
false
|
31
27
|
end
|
28
|
+
|
29
|
+
def to_omml_without_math_tag
|
30
|
+
groupchr = Utility.ox_element("groupChr", namespace: "m")
|
31
|
+
Utility.update_nodes(
|
32
|
+
groupchr,
|
33
|
+
[
|
34
|
+
group_chr_pr,
|
35
|
+
omml_parameter(parameter_one, tag_name: "e"),
|
36
|
+
],
|
37
|
+
)
|
38
|
+
[groupchr]
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def group_chr_pr
|
44
|
+
groupchrpr = Utility.ox_element("groupChrPr", namespace: "m")
|
45
|
+
vert_jc = Utility.ox_element("vertJc", namespace: "m", attributes: { "m:val": "bot" })
|
46
|
+
chr = Utility.ox_element("chr", namespace: "m", attributes: { "m:val": "⏞" })
|
47
|
+
pos = Utility.ox_element("pos", namespace: "m", attributes: { "m:val": "top" })
|
48
|
+
Utility.update_nodes(
|
49
|
+
groupchrpr,
|
50
|
+
[
|
51
|
+
chr,
|
52
|
+
pos,
|
53
|
+
vert_jc,
|
54
|
+
],
|
55
|
+
)
|
56
|
+
end
|
32
57
|
end
|
33
58
|
|
34
59
|
Overbrace = Obrace
|
@@ -1,15 +1,68 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
3
|
+
require_relative "ternary_function"
|
4
4
|
|
5
5
|
module Plurimath
|
6
6
|
module Math
|
7
7
|
module Function
|
8
|
-
class Oint <
|
8
|
+
class Oint < TernaryFunction
|
9
9
|
def to_asciimath
|
10
10
|
first_value = "_#{wrapped(parameter_one)}" if parameter_one
|
11
11
|
second_value = "^#{wrapped(parameter_two)}" if parameter_two
|
12
|
-
"oint#{first_value}#{second_value}"
|
12
|
+
"oint#{first_value}#{second_value} #{parameter_three&.to_asciimath}".strip
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_latex
|
16
|
+
first_value = "_#{latex_wrapped(parameter_one)}" if parameter_one
|
17
|
+
second_value = "^#{latex_wrapped(parameter_two)}" if parameter_two
|
18
|
+
"\\#{class_name}#{first_value}#{second_value} #{parameter_three&.to_latex}".strip
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_mathml_without_math_tag
|
22
|
+
mo_tag = Utility.ox_element("mo") << invert_unicode_symbols.to_s
|
23
|
+
return mo_tag unless all_values_exist?
|
24
|
+
|
25
|
+
msubsup_tag = Utility.ox_element("msubsup")
|
26
|
+
first_value = parameter_one&.to_mathml_without_math_tag if parameter_one
|
27
|
+
second_value = parameter_two&.to_mathml_without_math_tag if parameter_two
|
28
|
+
Utility.update_nodes(
|
29
|
+
msubsup_tag,
|
30
|
+
[
|
31
|
+
mo_tag,
|
32
|
+
first_value,
|
33
|
+
second_value,
|
34
|
+
],
|
35
|
+
)
|
36
|
+
return msubsup_tag if parameter_three.nil?
|
37
|
+
|
38
|
+
Utility.update_nodes(
|
39
|
+
Utility.ox_element("mrow"),
|
40
|
+
[
|
41
|
+
msubsup_tag,
|
42
|
+
parameter_three&.to_mathml_without_math_tag,
|
43
|
+
].flatten.compact,
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_omml_without_math_tag
|
48
|
+
if all_values_exist?
|
49
|
+
nary = Utility.ox_element("nary", namespace: "m")
|
50
|
+
Utility.update_nodes(
|
51
|
+
nary,
|
52
|
+
[
|
53
|
+
narypr("∮", function_type: "subSup"),
|
54
|
+
omml_parameter(parameter_one, tag_name: "sub"),
|
55
|
+
omml_parameter(parameter_two, tag_name: "sup"),
|
56
|
+
omml_parameter(parameter_three, tag_name: "e"),
|
57
|
+
],
|
58
|
+
)
|
59
|
+
[nary]
|
60
|
+
else
|
61
|
+
r_tag = Utility.ox_element("r", namespace: "m")
|
62
|
+
t_tag = Utility.ox_element("t", namespace: "m")
|
63
|
+
r_tag << (t_tag << "∮")
|
64
|
+
[r_tag]
|
65
|
+
end
|
13
66
|
end
|
14
67
|
end
|
15
68
|
end
|
@@ -9,7 +9,7 @@ module Plurimath
|
|
9
9
|
def to_asciimath
|
10
10
|
first_value = wrapped(parameter_one)
|
11
11
|
second_value = wrapped(parameter_two)
|
12
|
-
"
|
12
|
+
"frac#{first_value}#{second_value}"
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_mathml_without_math_tag
|
@@ -30,6 +30,20 @@ module Plurimath
|
|
30
30
|
two_value = parameter_two&.to_latex
|
31
31
|
"{#{first_value} \\over #{two_value}}"
|
32
32
|
end
|
33
|
+
|
34
|
+
def to_omml_without_math_tag
|
35
|
+
f_element = Utility.ox_element("f", namespace: "m")
|
36
|
+
fpr_element = Utility.ox_element("fPr", namespace: "m")
|
37
|
+
Utility.update_nodes(
|
38
|
+
f_element,
|
39
|
+
[
|
40
|
+
fpr_element << Utility.pr_element("ctrl", true, namespace: "m"),
|
41
|
+
omml_parameter(parameter_one, tag_name: "num"),
|
42
|
+
omml_parameter(parameter_two, tag_name: "den"),
|
43
|
+
],
|
44
|
+
)
|
45
|
+
[f_element]
|
46
|
+
end
|
33
47
|
end
|
34
48
|
end
|
35
49
|
end
|
@@ -7,7 +7,7 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Phantom < UnaryFunction
|
9
9
|
def to_asciimath
|
10
|
-
"
|
10
|
+
"#{Array.new(parameter_one&.length, '\ ').join}"
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_html
|
@@ -15,12 +15,15 @@ module Plurimath
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_latex
|
18
|
-
|
18
|
+
Array.new(parameter_one&.length, '\\ ').join
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_mathml_without_math_tag
|
22
|
-
|
23
|
-
Utility.
|
22
|
+
phantom = Utility.ox_element("mphantom")
|
23
|
+
Utility.update_nodes(
|
24
|
+
phantom,
|
25
|
+
parameter_one&.map(&:to_mathml_without_math_tag),
|
26
|
+
)
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -27,16 +27,12 @@ module Plurimath
|
|
27
27
|
def to_omml_without_math_tag
|
28
28
|
rad_element = Utility.ox_element("rad", namespace: "m")
|
29
29
|
pr_element = Utility.ox_element("radPr", namespace: "m")
|
30
|
-
deg_element = Utility.ox_element("deg", namespace: "m")
|
31
|
-
e_element = Utility.ox_element("e", namespace: "m")
|
32
|
-
Utility.update_nodes(e_element, parameter_one.to_omml_without_math_tag)
|
33
|
-
Utility.update_nodes(deg_element, parameter_two.to_omml_without_math_tag)
|
34
30
|
Utility.update_nodes(
|
35
31
|
rad_element,
|
36
32
|
[
|
37
33
|
(pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
|
38
|
-
|
39
|
-
|
34
|
+
omml_parameter(parameter_two, tag_name: "deg"),
|
35
|
+
omml_parameter(parameter_one, tag_name: "e"),
|
40
36
|
],
|
41
37
|
)
|
42
38
|
[rad_element]
|
@@ -21,14 +21,12 @@ module Plurimath
|
|
21
21
|
namespace: "m",
|
22
22
|
attributes: { "m:val": "1" },
|
23
23
|
)
|
24
|
-
e_element = Utility.ox_element("e", namespace: "m")
|
25
|
-
Utility.update_nodes(e_element, omml_value)
|
26
24
|
Utility.update_nodes(
|
27
25
|
rad_element,
|
28
26
|
[
|
29
27
|
(pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
|
30
28
|
Utility.ox_element("deg", namespace: "m"),
|
31
|
-
|
29
|
+
omml_parameter(parameter_one, tag_name: "e"),
|
32
30
|
],
|
33
31
|
)
|
34
32
|
[rad_element]
|
@@ -27,6 +27,21 @@ module Plurimath
|
|
27
27
|
"#{first_value}#{second_value}"
|
28
28
|
end
|
29
29
|
|
30
|
+
def to_omml_without_math_tag
|
31
|
+
limupp = Utility.ox_element("limUpp", namespace: "m")
|
32
|
+
limupppr = Utility.ox_element("limUppPr", namespace: "m")
|
33
|
+
limupppr << Utility.pr_element("ctrl", true, namespace: "m")
|
34
|
+
Utility.update_nodes(
|
35
|
+
limupp,
|
36
|
+
[
|
37
|
+
limupppr,
|
38
|
+
omml_parameter(parameter_two, tag_name: "e"),
|
39
|
+
omml_parameter(parameter_one, tag_name: "lim"),
|
40
|
+
],
|
41
|
+
)
|
42
|
+
[limupp]
|
43
|
+
end
|
44
|
+
|
30
45
|
protected
|
31
46
|
|
32
47
|
def wrapped(field)
|
@@ -18,6 +18,51 @@ module Plurimath
|
|
18
18
|
value_array << parameter_two.to_mathml_without_math_tag if parameter_two
|
19
19
|
Utility.update_nodes(Utility.ox_element("mtable"), value_array)
|
20
20
|
end
|
21
|
+
|
22
|
+
def to_omml_without_math_tag
|
23
|
+
Array(
|
24
|
+
Utility.update_nodes(
|
25
|
+
mm_element,
|
26
|
+
[
|
27
|
+
omml_parameter(parameter_one, tag_name: "mr"),
|
28
|
+
omml_parameter(parameter_two, tag_name: "mr"),
|
29
|
+
],
|
30
|
+
),
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def mm_element
|
37
|
+
mcjc = Utility.ox_element(
|
38
|
+
"mcJc",
|
39
|
+
namespace: "m",
|
40
|
+
attributes: { "m:val": "center" },
|
41
|
+
)
|
42
|
+
mcount = Utility.ox_element(
|
43
|
+
"count",
|
44
|
+
namespace: "m",
|
45
|
+
attributes: { "m:val": "1" },
|
46
|
+
)
|
47
|
+
mbasejc = Utility.ox_element(
|
48
|
+
"baseJc",
|
49
|
+
namespace: "m",
|
50
|
+
attributes: { "m:val": "center", },
|
51
|
+
)
|
52
|
+
mplchide = Utility.ox_element(
|
53
|
+
"plcHide",
|
54
|
+
namespace: "m",
|
55
|
+
attributes: { "m:val": "1" },
|
56
|
+
)
|
57
|
+
mm = Utility.ox_element("m", namespace: "m")
|
58
|
+
mc = Utility.ox_element("mc", namespace: "m")
|
59
|
+
mpr = Utility.ox_element("mpr", namespace: "m")
|
60
|
+
mcs = Utility.ox_element("mcs", namespace: "m")
|
61
|
+
mcpr = Utility.ox_element("mcPr", namespace: "m")
|
62
|
+
mc << Utility.update_nodes(mcpr, [mcjc, mcount])
|
63
|
+
mcs << mc
|
64
|
+
Utility.update_nodes(mm, [mpr])
|
65
|
+
end
|
21
66
|
end
|
22
67
|
end
|
23
68
|
end
|
@@ -51,10 +51,6 @@ module Plurimath
|
|
51
51
|
"#{first_value}#{second_value}#{third_value}"
|
52
52
|
end
|
53
53
|
|
54
|
-
def class_name
|
55
|
-
self.class.name.split("::").last.downcase
|
56
|
-
end
|
57
|
-
|
58
54
|
protected
|
59
55
|
|
60
56
|
def latex_wrapped(field)
|
@@ -129,6 +125,12 @@ module Plurimath
|
|
129
125
|
def all_values_exist?
|
130
126
|
!(parameter_one.nil? && parameter_two.nil? && parameter_three.nil?)
|
131
127
|
end
|
128
|
+
|
129
|
+
def validate_mathml_tag(parameter)
|
130
|
+
return Array(Utility.ox_element("mrow")) unless parameter
|
131
|
+
|
132
|
+
Array(parameter.to_mathml_without_math_tag)
|
133
|
+
end
|
132
134
|
end
|
133
135
|
end
|
134
136
|
end
|
@@ -12,6 +12,20 @@ module Plurimath
|
|
12
12
|
second_value = parameter_one.to_mathml_without_math_tag if parameter_one
|
13
13
|
Utility.update_nodes(mover, [second_value, first_value])
|
14
14
|
end
|
15
|
+
|
16
|
+
def to_omml_without_math_tag
|
17
|
+
acc_tag = Utility.ox_element("acc", namespace: "m")
|
18
|
+
acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
|
19
|
+
acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val": "˜" }))
|
20
|
+
Utility.update_nodes(
|
21
|
+
acc_tag,
|
22
|
+
[
|
23
|
+
acc_pr_tag,
|
24
|
+
omml_parameter(parameter_one, tag_name: "e"),
|
25
|
+
],
|
26
|
+
)
|
27
|
+
[acc_tag]
|
28
|
+
end
|
15
29
|
end
|
16
30
|
end
|
17
31
|
end
|
@@ -29,6 +29,22 @@ module Plurimath
|
|
29
29
|
def validate_function_formula
|
30
30
|
false
|
31
31
|
end
|
32
|
+
|
33
|
+
def to_omml_without_math_tag
|
34
|
+
limlow = Utility.ox_element("limLow", namespace: "m")
|
35
|
+
limlowpr = Utility.ox_element("limLowPr", namespace: "m")
|
36
|
+
limlowpr << Utility.pr_element("ctrl", true, namespace: "m")
|
37
|
+
lim = Utility.ox_element("lim", namespace: "m")
|
38
|
+
Utility.update_nodes(
|
39
|
+
limlow,
|
40
|
+
[
|
41
|
+
limlowpr,
|
42
|
+
omml_parameter(parameter_one, tag_name: "e"),
|
43
|
+
Utility.update_nodes(lim, r_element("⏟")),
|
44
|
+
],
|
45
|
+
)
|
46
|
+
[limlow]
|
47
|
+
end
|
32
48
|
end
|
33
49
|
|
34
50
|
Underbrace = Ubrace
|
@@ -16,6 +16,20 @@ module Plurimath
|
|
16
16
|
],
|
17
17
|
)
|
18
18
|
end
|
19
|
+
|
20
|
+
def to_omml_without_math_tag
|
21
|
+
acc_tag = Utility.ox_element("acc", namespace: "m")
|
22
|
+
acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
|
23
|
+
acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val": "→" }))
|
24
|
+
Utility.update_nodes(
|
25
|
+
acc_tag,
|
26
|
+
[
|
27
|
+
acc_pr_tag,
|
28
|
+
omml_parameter(parameter_one, tag_name: "e"),
|
29
|
+
],
|
30
|
+
)
|
31
|
+
[acc_tag]
|
32
|
+
end
|
19
33
|
end
|
20
34
|
end
|
21
35
|
end
|
@@ -21,10 +21,12 @@ module Plurimath
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def parse
|
24
|
-
ox_nodes = Ox.load(text, strip_namespace: true)
|
25
|
-
|
24
|
+
ox_nodes = Ox.load(text, strip_namespace: true)
|
25
|
+
display_style = ox_nodes&.locate("*/mstyle/@displaystyle")&.first
|
26
|
+
nodes = parse_nodes(ox_nodes.nodes)
|
26
27
|
Math::Formula.new(
|
27
28
|
Transform.new.apply(nodes).flatten.compact,
|
29
|
+
displaystyle: display_style
|
28
30
|
)
|
29
31
|
end
|
30
32
|
|
data/lib/plurimath/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|
@@ -183,7 +183,6 @@ files:
|
|
183
183
|
- lib/plurimath/math/function/ubrace.rb
|
184
184
|
- lib/plurimath/math/function/ul.rb
|
185
185
|
- lib/plurimath/math/function/unary_function.rb
|
186
|
-
- lib/plurimath/math/function/underline.rb
|
187
186
|
- lib/plurimath/math/function/underover.rb
|
188
187
|
- lib/plurimath/math/function/underset.rb
|
189
188
|
- lib/plurimath/math/function/vec.rb
|