plurimath 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.rspec +3 -0
- data/.rspec-opal +11 -0
- data/Gemfile +4 -0
- data/Rakefile +11 -0
- data/lib/plurimath/asciimath/parse.rb +3 -2
- data/lib/plurimath/asciimath/transform.rb +47 -5
- data/lib/plurimath/latex/constants.rb +5 -1
- data/lib/plurimath/latex/parse.rb +20 -11
- data/lib/plurimath/latex/transform.rb +32 -14
- data/lib/plurimath/math/core.rb +212 -10
- data/lib/plurimath/math/formula.rb +154 -40
- data/lib/plurimath/math/function/abs.rb +28 -15
- data/lib/plurimath/math/function/bar.rb +5 -0
- data/lib/plurimath/math/function/base.rb +22 -2
- data/lib/plurimath/math/function/binary_function.rb +38 -12
- data/lib/plurimath/math/function/ceil.rb +24 -9
- data/lib/plurimath/math/function/color.rb +14 -0
- data/lib/plurimath/math/function/ddot.rb +6 -1
- data/lib/plurimath/math/function/deg.rb +4 -1
- data/lib/plurimath/math/function/det.rb +4 -1
- data/lib/plurimath/math/function/dim.rb +4 -1
- data/lib/plurimath/math/function/dot.rb +5 -0
- data/lib/plurimath/math/function/exp.rb +4 -1
- data/lib/plurimath/math/function/fenced.rb +51 -15
- data/lib/plurimath/math/function/floor.rb +24 -14
- data/lib/plurimath/math/function/font_style.rb +63 -8
- data/lib/plurimath/math/function/frac.rb +38 -18
- data/lib/plurimath/math/function/gcd.rb +4 -1
- data/lib/plurimath/math/function/glb.rb +8 -1
- data/lib/plurimath/math/function/hat.rb +16 -5
- data/lib/plurimath/math/function/hom.rb +4 -1
- data/lib/plurimath/math/function/inf.rb +16 -0
- data/lib/plurimath/math/function/int.rb +35 -9
- data/lib/plurimath/math/function/ker.rb +4 -1
- data/lib/plurimath/math/function/lcm.rb +17 -1
- data/lib/plurimath/math/function/left.rb +20 -2
- data/lib/plurimath/math/function/lg.rb +4 -1
- data/lib/plurimath/math/function/lim.rb +16 -0
- data/lib/plurimath/math/function/liminf.rb +4 -1
- data/lib/plurimath/math/function/limits.rb +29 -9
- data/lib/plurimath/math/function/limsup.rb +4 -1
- data/lib/plurimath/math/function/linebreak.rb +95 -0
- data/lib/plurimath/math/function/ln.rb +4 -1
- data/lib/plurimath/math/function/log.rb +27 -12
- data/lib/plurimath/math/function/longdiv.rb +19 -0
- data/lib/plurimath/math/function/lub.rb +4 -1
- data/lib/plurimath/math/function/max.rb +4 -1
- data/lib/plurimath/math/function/mbox.rb +8 -7
- data/lib/plurimath/math/function/menclose.rb +6 -0
- data/lib/plurimath/math/function/merror.rb +12 -3
- data/lib/plurimath/math/function/min.rb +4 -1
- data/lib/plurimath/math/function/mod.rb +48 -15
- data/lib/plurimath/math/function/msgroup.rb +32 -0
- data/lib/plurimath/math/function/msline.rb +10 -0
- data/lib/plurimath/math/function/multiscript.rb +27 -0
- data/lib/plurimath/math/function/nary.rb +128 -0
- data/lib/plurimath/math/function/norm.rb +24 -15
- data/lib/plurimath/math/function/obrace.rb +5 -0
- data/lib/plurimath/math/function/oint.rb +48 -20
- data/lib/plurimath/math/function/over.rb +29 -10
- data/lib/plurimath/math/function/overset.rb +19 -10
- data/lib/plurimath/math/function/phantom.rb +24 -6
- data/lib/plurimath/math/function/power.rb +19 -4
- data/lib/plurimath/math/function/power_base.rb +34 -33
- data/lib/plurimath/math/function/prod.rb +43 -23
- data/lib/plurimath/math/function/right.rb +20 -2
- data/lib/plurimath/math/function/root.rb +6 -0
- data/lib/plurimath/math/function/rule.rb +8 -1
- data/lib/plurimath/math/function/scarries.rb +14 -0
- data/lib/plurimath/math/function/semantics.rb +15 -0
- data/lib/plurimath/math/function/sqrt.rb +5 -0
- data/lib/plurimath/math/function/stackrel.rb +14 -0
- data/lib/plurimath/math/function/substack.rb +18 -51
- data/lib/plurimath/math/function/sum.rb +36 -12
- data/lib/plurimath/math/function/sup.rb +11 -2
- data/lib/plurimath/math/function/table/array.rb +1 -1
- data/lib/plurimath/math/function/table/matrix.rb +4 -0
- data/lib/plurimath/math/function/table.rb +62 -26
- data/lib/plurimath/math/function/td.rb +42 -4
- data/lib/plurimath/math/function/ternary_function.rb +48 -10
- data/lib/plurimath/math/function/text.rb +25 -3
- data/lib/plurimath/math/function/tilde.rb +5 -0
- data/lib/plurimath/math/function/tr.rb +29 -1
- data/lib/plurimath/math/function/ubrace.rb +5 -0
- data/lib/plurimath/math/function/unary_function.rb +115 -29
- data/lib/plurimath/math/function/underover.rb +27 -58
- data/lib/plurimath/math/function/underset.rb +25 -9
- data/lib/plurimath/math/function/vec.rb +45 -0
- data/lib/plurimath/math/function.rb +7 -5
- data/lib/plurimath/math/number.rb +12 -8
- data/lib/plurimath/math/symbol.rb +25 -13
- data/lib/plurimath/math.rb +1 -3
- data/lib/plurimath/mathml/parser.rb +6 -4
- data/lib/plurimath/mathml/transform.rb +26 -19
- data/lib/plurimath/omml/parser.rb +3 -3
- data/lib/plurimath/omml/transform.rb +34 -21
- data/lib/plurimath/setup/oga.rb +5 -0
- data/lib/plurimath/setup/opal.rb.erb +8 -0
- data/lib/plurimath/setup/ox.rb +5 -0
- data/lib/plurimath/unitsml.rb +2 -1
- data/lib/plurimath/utility.rb +77 -41
- data/lib/plurimath/version.rb +1 -1
- data/lib/plurimath/xml_engine/oga.rb +246 -0
- data/lib/plurimath/xml_engine/ox.rb +29 -0
- data/lib/plurimath/xml_engine.rb +6 -0
- data/lib/plurimath.rb +12 -2
- metadata +12 -3
- data/lib/plurimath/math/function/scarry.rb +0 -12
@@ -16,7 +16,7 @@ module Plurimath
|
|
16
16
|
mo
|
17
17
|
end
|
18
18
|
|
19
|
-
def to_omml_without_math_tag(
|
19
|
+
def to_omml_without_math_tag(_)
|
20
20
|
mr = Utility.ox_element("m:r")
|
21
21
|
if parameter_one
|
22
22
|
mt = Utility.ox_element("m:t")
|
@@ -30,13 +30,31 @@ module Plurimath
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_latex
|
33
|
-
"\\right #{
|
33
|
+
"\\right #{latex_paren}"
|
34
34
|
end
|
35
35
|
|
36
36
|
def validate_function_formula
|
37
37
|
false
|
38
38
|
end
|
39
39
|
|
40
|
+
def to_asciimath_math_zone(spacing = "", _, _)
|
41
|
+
"#{spacing}\"#{latex_paren}\" right\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_latex_math_zone(spacing = "", _, _)
|
45
|
+
"#{spacing}\"#{latex_paren}\" right\n"
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_mathml_math_zone(spacing = "", _, _)
|
49
|
+
mo_tag = (Utility.ox_element("mo") << right_paren)
|
50
|
+
"#{spacing}\"#{dump_ox_nodes(mo_tag).gsub(/\s+/, "")}\" right\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_omml_math_zone(spacing = "", _, _, display_style:)
|
54
|
+
t_tag = (Utility.ox_element("t", namespace: "m") << right_paren)
|
55
|
+
"#{spacing}\"#{dump_ox_nodes(t_tag).gsub(/\s+/, "")}\" right\n"
|
56
|
+
end
|
57
|
+
|
40
58
|
protected
|
41
59
|
|
42
60
|
def right_paren
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Root < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "root",
|
11
|
+
first_value: "radicand",
|
12
|
+
second_value: "index",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_mathml_without_math_tag
|
10
16
|
first_value = parameter_one&.to_mathml_without_math_tag
|
11
17
|
second_value = parameter_two&.to_mathml_without_math_tag
|
@@ -5,6 +5,13 @@ module Plurimath
|
|
5
5
|
module Math
|
6
6
|
module Function
|
7
7
|
class Rule < TernaryFunction
|
8
|
+
FUNCTION = {
|
9
|
+
name: "rule",
|
10
|
+
first_value: "first argument",
|
11
|
+
second_value: "second argument",
|
12
|
+
third_value: "third argument",
|
13
|
+
}.freeze
|
14
|
+
|
8
15
|
def to_asciimath
|
9
16
|
""
|
10
17
|
end
|
@@ -20,7 +27,7 @@ module Plurimath
|
|
20
27
|
Utility.ox_element("mi")
|
21
28
|
end
|
22
29
|
|
23
|
-
def to_omml_without_math_tag(
|
30
|
+
def to_omml_without_math_tag(_)
|
24
31
|
[Utility.ox_element("m:r") << Utility.ox_element("m:t")]
|
25
32
|
end
|
26
33
|
|
@@ -6,6 +6,20 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Scarries < UnaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
asciimath_value
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_latex
|
14
|
+
latex_value
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_mathml_without_math_tag
|
18
|
+
scarries_tag = Utility.ox_element("mscarries")
|
19
|
+
Utility.update_nodes(scarries_tag, mathml_value)
|
20
|
+
scarries_tag
|
21
|
+
end
|
22
|
+
|
9
23
|
def to_omml_without_math_tag(display_style)
|
10
24
|
omml_value(display_style)
|
11
25
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Semantics < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "semantics",
|
11
|
+
first_value: "first argument",
|
12
|
+
second_value: "second argument",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_mathml_without_math_tag
|
10
16
|
first_value = parameter_one&.to_mathml_without_math_tag
|
11
17
|
second_value = other_tags(parameter_two)
|
@@ -27,6 +33,15 @@ module Plurimath
|
|
27
33
|
Array(parameter_one.insert_t_tag(display_style))
|
28
34
|
end
|
29
35
|
|
36
|
+
def line_breaking(obj)
|
37
|
+
parameter_one&.line_breaking(obj)
|
38
|
+
if obj.value_exist?
|
39
|
+
semantics = self.class.new(Utility.filter_values(obj.value), self.parameter_two)
|
40
|
+
self.parameter_two = nil
|
41
|
+
obj.update(semantics)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
30
45
|
protected
|
31
46
|
|
32
47
|
def other_tags(array)
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Stackrel < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "stackrel",
|
11
|
+
first_value: "above",
|
12
|
+
second_value: "below",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
first_value = wrapped(parameter_one)
|
11
17
|
second_value = wrapped(parameter_two)
|
@@ -42,6 +48,14 @@ module Plurimath
|
|
42
48
|
[limupp]
|
43
49
|
end
|
44
50
|
|
51
|
+
def line_breaking(obj)
|
52
|
+
parameter_one.line_breaking(obj)
|
53
|
+
if obj.value_exist?
|
54
|
+
obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two))
|
55
|
+
self.parameter_two = nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
45
59
|
protected
|
46
60
|
|
47
61
|
def wrapped(field)
|
@@ -1,67 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
3
|
+
require_relative "unary_function"
|
4
4
|
|
5
5
|
module Plurimath
|
6
6
|
module Math
|
7
7
|
module Function
|
8
|
-
class Substack <
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
class Substack < UnaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "substack",
|
11
|
+
first_value: "above",
|
12
|
+
second_value: "below",
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
def to_asciimath
|
16
|
+
"{:#{parameter_one.compact.map(&:to_asciimath).join(",")}:}"
|
13
17
|
end
|
14
18
|
|
15
|
-
def
|
16
|
-
|
17
|
-
value_array << parameter_one.to_mathml_without_math_tag if parameter_one
|
18
|
-
value_array << parameter_two.to_mathml_without_math_tag if parameter_two
|
19
|
-
Utility.update_nodes(Utility.ox_element("mtable"), value_array)
|
19
|
+
def to_latex
|
20
|
+
"\\#{class_name}{#{parameter_one&.compact&.map(&:to_latex)&.join(" \\\\ ")}}"
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
-
|
24
|
-
Utility.
|
25
|
-
|
26
|
-
[
|
27
|
-
omml_parameter(parameter_one, display_style, tag_name: "mr"),
|
28
|
-
omml_parameter(parameter_two, display_style, tag_name: "mr"),
|
29
|
-
],
|
30
|
-
),
|
23
|
+
def to_mathml_without_math_tag
|
24
|
+
Utility.update_nodes(
|
25
|
+
Utility.ox_element("mtable"),
|
26
|
+
mathml_value,
|
31
27
|
)
|
32
28
|
end
|
33
29
|
|
34
|
-
|
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])
|
30
|
+
def to_omml_without_math_tag(display_style)
|
31
|
+
Table.new(parameter_one).to_omml_without_math_tag(display_style)
|
65
32
|
end
|
66
33
|
end
|
67
34
|
end
|
@@ -6,6 +6,13 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Sum < TernaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "summation",
|
11
|
+
first_value: "subscript",
|
12
|
+
second_value: "supscript",
|
13
|
+
third_value: "term",
|
14
|
+
}.freeze
|
15
|
+
|
9
16
|
def to_asciimath
|
10
17
|
first_value = "_#{wrapped(parameter_one)}" if parameter_one
|
11
18
|
second_value = "^#{wrapped(parameter_two)}" if parameter_two
|
@@ -19,29 +26,29 @@ module Plurimath
|
|
19
26
|
end
|
20
27
|
|
21
28
|
def to_mathml_without_math_tag
|
22
|
-
first_value =
|
29
|
+
first_value = ox_element("mo")
|
30
|
+
first_value << invert_unicode_symbols.to_s unless hide_function_name
|
31
|
+
|
23
32
|
if parameter_one || parameter_two
|
24
|
-
value_array = [
|
25
|
-
|
26
|
-
|
33
|
+
value_array = [
|
34
|
+
parameter_one&.to_mathml_without_math_tag,
|
35
|
+
parameter_two&.to_mathml_without_math_tag,
|
36
|
+
]
|
27
37
|
tag_name = if parameter_two && parameter_one
|
28
38
|
"underover"
|
29
39
|
else
|
30
40
|
parameter_one ? "under" : "over"
|
31
41
|
end
|
32
|
-
munderover_tag =
|
33
|
-
Utility.update_nodes(
|
34
|
-
munderover_tag,
|
35
|
-
value_array.insert(0, first_value),
|
36
|
-
)
|
42
|
+
munderover_tag = ox_element("m#{tag_name}")
|
43
|
+
Utility.update_nodes(munderover_tag, value_array.insert(0, first_value))
|
37
44
|
return munderover_tag if parameter_three.nil?
|
38
45
|
|
39
46
|
Utility.update_nodes(
|
40
|
-
|
47
|
+
ox_element("mrow"),
|
41
48
|
[
|
42
49
|
munderover_tag,
|
43
50
|
parameter_three&.to_mathml_without_math_tag,
|
44
|
-
]
|
51
|
+
],
|
45
52
|
)
|
46
53
|
else
|
47
54
|
first_value
|
@@ -61,7 +68,7 @@ module Plurimath
|
|
61
68
|
Utility.update_nodes(
|
62
69
|
nary,
|
63
70
|
[
|
64
|
-
narypr("∑"),
|
71
|
+
narypr(hide_function_name ? "" : "∑"),
|
65
72
|
omml_parameter(parameter_one, display_style, tag_name: "sub"),
|
66
73
|
omml_parameter(parameter_two, display_style, tag_name: "sup"),
|
67
74
|
omml_parameter(parameter_three, display_style, tag_name: "e"),
|
@@ -77,6 +84,23 @@ module Plurimath
|
|
77
84
|
def nary_attr_value
|
78
85
|
"∑"
|
79
86
|
end
|
87
|
+
|
88
|
+
def line_breaking(obj)
|
89
|
+
parameter_one&.line_breaking(obj)
|
90
|
+
if obj.value_exist?
|
91
|
+
sum = self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
|
92
|
+
sum.hide_function_name = true
|
93
|
+
obj.update(sum)
|
94
|
+
self.parameter_two = nil
|
95
|
+
self.parameter_three = nil
|
96
|
+
return
|
97
|
+
end
|
98
|
+
|
99
|
+
parameter_three&.line_breaking(obj)
|
100
|
+
if obj.value_exist?
|
101
|
+
obj.update(Utility.filter_values(obj.value))
|
102
|
+
end
|
103
|
+
end
|
80
104
|
end
|
81
105
|
end
|
82
106
|
end
|
@@ -7,11 +7,20 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Sup < UnaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
|
-
Utility.ox_element("mo") << "sup"
|
10
|
+
mo_tag = Utility.ox_element("mo") << "sup"
|
11
|
+
first_value = mathml_value
|
12
|
+
first_value = mathml_value&.insert(0, mo_tag) unless hide_function_name
|
13
|
+
Utility.update_nodes(
|
14
|
+
ox_element("mrow"),
|
15
|
+
first_value,
|
16
|
+
)
|
11
17
|
end
|
12
18
|
|
13
19
|
def to_omml_without_math_tag(display_style)
|
14
|
-
|
20
|
+
array = []
|
21
|
+
array << r_element("sup", rpr_tag: false) unless hide_function_name
|
22
|
+
array += Array(omml_value(display_style))
|
23
|
+
array
|
15
24
|
end
|
16
25
|
end
|
17
26
|
end
|
@@ -6,6 +6,8 @@ module Plurimath
|
|
6
6
|
class Table < Core
|
7
7
|
attr_accessor :value, :open_paren, :close_paren, :options
|
8
8
|
|
9
|
+
SIMPLE_TABLES = %w[array align split].freeze
|
10
|
+
|
9
11
|
def initialize(value = nil,
|
10
12
|
open_paren = nil,
|
11
13
|
close_paren = nil,
|
@@ -25,6 +27,8 @@ module Plurimath
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def to_asciimath
|
30
|
+
return parentheless_table if SIMPLE_TABLES.include?(class_name)
|
31
|
+
|
28
32
|
parenthesis = Asciimath::Constants::TABLE_PARENTHESIS
|
29
33
|
first_value = value.map(&:to_asciimath).join(", ")
|
30
34
|
third_value = close_paren.is_a?(::Array) || close_paren.nil?
|
@@ -52,13 +56,11 @@ module Plurimath
|
|
52
56
|
end
|
53
57
|
|
54
58
|
def to_latex
|
55
|
-
if open_paren == "norm["
|
56
|
-
return "\\begin{Vmatrix}#{latex_content}\\end{Vmatrix}"
|
57
|
-
end
|
59
|
+
return "\\begin{Vmatrix}#{latex_content}\\end{Vmatrix}" if open_paren == "norm["
|
58
60
|
|
59
61
|
separator = "{#{table_attribute(:latex)}}" if environment&.include?("array")
|
60
|
-
left_paren = latex_parenthesis(open_paren)
|
61
|
-
right_paren = latex_parenthesis(close_paren)
|
62
|
+
left_paren = latex_parenthesis(open_paren)
|
63
|
+
right_paren = latex_parenthesis(close_paren)
|
62
64
|
left = "\\left #{left_paren}\\begin{matrix}"
|
63
65
|
right = "\\end{matrix}\\right #{right_paren}"
|
64
66
|
"#{left}#{separator}#{latex_content}#{right}"
|
@@ -70,11 +72,40 @@ module Plurimath
|
|
70
72
|
end
|
71
73
|
|
72
74
|
def to_omml_without_math_tag(display_style)
|
73
|
-
if value.map { |d| d.parameter_one.length == 1 }.all?
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
ox_table = if value.map { |d| d.parameter_one.length == 1 }.all?
|
76
|
+
single_td_table(display_style)
|
77
|
+
else
|
78
|
+
multiple_td_table(display_style)
|
79
|
+
end
|
80
|
+
fenced_table(ox_table)
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_asciimath_math_zone(spacing, last = false, indent = true)
|
84
|
+
[
|
85
|
+
"#{spacing}\"table\" function apply\n",
|
86
|
+
Formula.new(value).to_asciimath_math_zone(gsub_spacing(spacing, last), last, indent),
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def to_latex_math_zone(spacing, last = false, indent = true)
|
91
|
+
[
|
92
|
+
"#{spacing}\"table\" function apply\n",
|
93
|
+
Formula.new(value).to_latex_math_zone(gsub_spacing(spacing, last), last, indent),
|
94
|
+
]
|
95
|
+
end
|
96
|
+
|
97
|
+
def to_mathml_math_zone(spacing, last = false, indent = true)
|
98
|
+
[
|
99
|
+
"#{spacing}\"table\" function apply\n",
|
100
|
+
Formula.new(value).to_mathml_math_zone(gsub_spacing(spacing, last), last, indent),
|
101
|
+
]
|
102
|
+
end
|
103
|
+
|
104
|
+
def to_omml_math_zone(spacing, last = false, indent = true, display_style:)
|
105
|
+
[
|
106
|
+
"#{spacing}\"table\" function apply\n",
|
107
|
+
Formula.new(value).to_omml_math_zone(gsub_spacing(spacing, last), last, indent, display_style: display_style),
|
108
|
+
]
|
78
109
|
end
|
79
110
|
|
80
111
|
protected
|
@@ -90,6 +121,7 @@ module Plurimath
|
|
90
121
|
end
|
91
122
|
|
92
123
|
def latex_parenthesis(field)
|
124
|
+
return "." unless field
|
93
125
|
return " ." if field&.include?(":")
|
94
126
|
|
95
127
|
return "\\#{field}" if ["{", "}"].include?(field)
|
@@ -165,7 +197,7 @@ module Plurimath
|
|
165
197
|
eqarrpr = Utility.ox_element("eqArrPr", namespace: "m")
|
166
198
|
eqarrpr << Utility.pr_element("ctrl", true, namespace: "m")
|
167
199
|
eqarr << eqarrpr
|
168
|
-
tr_value = value.map { |
|
200
|
+
tr_value = value.map { |object| object.to_omml_without_math_tag(display_style) }.flatten
|
169
201
|
Utility.update_nodes(eqarr, tr_value.compact)
|
170
202
|
[eqarr]
|
171
203
|
end
|
@@ -194,7 +226,7 @@ module Plurimath
|
|
194
226
|
mcs << mc
|
195
227
|
mpr << mcs
|
196
228
|
mpr << ctrlpr
|
197
|
-
mm_value = value&.map { |
|
229
|
+
mm_value = value&.map { |object| object.to_omml_without_math_tag(display_style) }
|
198
230
|
Utility.update_nodes(
|
199
231
|
mm,
|
200
232
|
mm_value.insert(0, mpr).flatten,
|
@@ -215,7 +247,7 @@ module Plurimath
|
|
215
247
|
end
|
216
248
|
|
217
249
|
def fenced_table(ox_table)
|
218
|
-
return ox_table unless open_paren
|
250
|
+
return ox_table unless open_paren || close_paren
|
219
251
|
|
220
252
|
d_node = Utility.ox_element("d", namespace: "m")
|
221
253
|
e_node = Utility.ox_element("e", namespace: "m")
|
@@ -225,22 +257,22 @@ module Plurimath
|
|
225
257
|
end
|
226
258
|
|
227
259
|
def mdpr_node
|
228
|
-
begchr = Utility.ox_element("begChr", namespace: "m")
|
229
|
-
begchr.attributes["m:val"] = paren(open_paren)
|
230
|
-
endchr = Utility.ox_element("endChr", namespace: "m")
|
231
|
-
endchr.attributes["m:val"] = paren(close_paren)
|
232
260
|
sepchr = Utility.ox_element("sepChr", attributes: { "m:val": "" }, namespace: "m")
|
233
261
|
mgrow = Utility.ox_element("grow", namespace: "m")
|
234
262
|
mdpr = Utility.ox_element("dPr", namespace: "m")
|
235
|
-
Utility.update_nodes(
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
263
|
+
Utility.update_nodes(mdpr, [begchr, endchr, sepchr, mgrow])
|
264
|
+
end
|
265
|
+
|
266
|
+
def begchr
|
267
|
+
return unless open_paren
|
268
|
+
|
269
|
+
Utility.ox_element("begChr", attributes: { "m:val": paren(open_paren) }, namespace: "m")
|
270
|
+
end
|
271
|
+
|
272
|
+
def endchr
|
273
|
+
return unless close_paren
|
274
|
+
|
275
|
+
Utility.ox_element("endChr", attributes: { "m:val": paren(close_paren) }, namespace: "m")
|
244
276
|
end
|
245
277
|
|
246
278
|
def paren(parenthesis)
|
@@ -248,6 +280,10 @@ module Plurimath
|
|
248
280
|
|
249
281
|
parenthesis
|
250
282
|
end
|
283
|
+
|
284
|
+
def parentheless_table
|
285
|
+
"{:#{value.map(&:to_asciimath).join(", ")}:}"
|
286
|
+
end
|
251
287
|
end
|
252
288
|
end
|
253
289
|
end
|
@@ -36,12 +36,50 @@ module Plurimath
|
|
36
36
|
me = Utility.ox_element("e", namespace: "m")
|
37
37
|
return [me] if parameter_one&.empty?
|
38
38
|
|
39
|
-
Utility.update_nodes(
|
40
|
-
me,
|
41
|
-
Formula.new(parameter_one).omml_content(display_style),
|
42
|
-
)
|
39
|
+
Utility.update_nodes(me, omml_content(display_style))
|
43
40
|
[me]
|
44
41
|
end
|
42
|
+
|
43
|
+
def to_asciimath_math_zone(spacing, last = false, _)
|
44
|
+
[
|
45
|
+
"#{spacing}\"td\" function apply\n",
|
46
|
+
Formula.new(parameter_one).to_asciimath_math_zone(gsub_spacing(spacing, last), last),
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_latex_math_zone(spacing, last = false, indent = true)
|
51
|
+
[
|
52
|
+
"#{spacing}\"td\" function apply\n",
|
53
|
+
Formula.new(parameter_one).to_latex_math_zone(gsub_spacing(spacing, last), last, indent),
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_mathml_math_zone(spacing, last = false, indent = true)
|
58
|
+
[
|
59
|
+
"#{spacing}\"td\" function apply\n",
|
60
|
+
Formula.new(parameter_one).to_mathml_math_zone(gsub_spacing(spacing, last), last, indent),
|
61
|
+
]
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_omml_math_zone(spacing, last = false, indent = true, display_style:)
|
65
|
+
[
|
66
|
+
"#{spacing}\"td\" function apply\n",
|
67
|
+
Formula.new(parameter_one).to_omml_math_zone(gsub_spacing(spacing, last), last, indent, display_style: display_style),
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
71
|
+
def omml_content(display_style)
|
72
|
+
parameter_one&.map { |val| val.insert_t_tag(display_style) }
|
73
|
+
end
|
74
|
+
|
75
|
+
def line_breaking(obj)
|
76
|
+
sliced_value = result(Array(parameter_one))
|
77
|
+
return unless sliced_value.length > 1
|
78
|
+
|
79
|
+
sliced_result = sliced_value.first.last.omml_line_break(sliced_value)
|
80
|
+
table = Table.new(sliced_result.map { |res| Tr.new(Array(Td.new(Array(res)))) })
|
81
|
+
self.parameter_one = [table]
|
82
|
+
end
|
45
83
|
end
|
46
84
|
end
|
47
85
|
end
|