plurimath 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/Latex-Supported-Data.adoc +1 -0
- data/lib/plurimath/asciimath/parse.rb +1 -1
- data/lib/plurimath/asciimath/transform.rb +2 -6
- data/lib/plurimath/latex/constants.rb +2 -0
- data/lib/plurimath/math/core.rb +38 -6
- data/lib/plurimath/math/formula.rb +60 -6
- data/lib/plurimath/math/function/abs.rb +4 -0
- data/lib/plurimath/math/function/arg.rb +22 -0
- data/lib/plurimath/math/function/bar.rb +4 -0
- data/lib/plurimath/math/function/base.rb +49 -0
- data/lib/plurimath/math/function/binary_function.rb +6 -0
- data/lib/plurimath/math/function/cancel.rb +5 -0
- data/lib/plurimath/math/function/ceil.rb +6 -0
- data/lib/plurimath/math/function/color.rb +20 -1
- data/lib/plurimath/math/function/ddot.rb +4 -0
- data/lib/plurimath/math/function/dot.rb +5 -0
- data/lib/plurimath/math/function/fenced.rb +98 -7
- data/lib/plurimath/math/function/floor.rb +6 -0
- data/lib/plurimath/math/function/font_style/monospace.rb +4 -0
- data/lib/plurimath/math/function/font_style.rb +31 -6
- data/lib/plurimath/math/function/frac.rb +69 -15
- data/lib/plurimath/math/function/hat.rb +4 -0
- data/lib/plurimath/math/function/inf.rb +30 -0
- data/lib/plurimath/math/function/int.rb +47 -1
- data/lib/plurimath/math/function/intent.rb +22 -0
- data/lib/plurimath/math/function/left.rb +4 -0
- data/lib/plurimath/math/function/lim.rb +6 -0
- data/lib/plurimath/math/function/limits.rb +28 -0
- data/lib/plurimath/math/function/linebreak.rb +5 -0
- data/lib/plurimath/math/function/log.rb +27 -20
- data/lib/plurimath/math/function/longdiv.rb +4 -0
- data/lib/plurimath/math/function/mbox.rb +4 -0
- data/lib/plurimath/math/function/menclose.rb +74 -5
- data/lib/plurimath/math/function/merror.rb +2 -0
- data/lib/plurimath/math/function/mglyph.rb +64 -0
- data/lib/plurimath/math/function/mlabeledtr.rb +29 -0
- data/lib/plurimath/math/function/mod.rb +4 -0
- data/lib/plurimath/math/function/mpadded.rb +84 -0
- data/lib/plurimath/math/function/ms.rb +33 -0
- data/lib/plurimath/math/function/msgroup.rb +4 -0
- data/lib/plurimath/math/function/msline.rb +2 -4
- data/lib/plurimath/math/function/multiscript.rb +70 -6
- data/lib/plurimath/math/function/nary.rb +69 -10
- data/lib/plurimath/math/function/none.rb +25 -0
- data/lib/plurimath/math/function/norm.rb +6 -0
- data/lib/plurimath/math/function/obrace.rb +4 -0
- data/lib/plurimath/math/function/oint.rb +25 -1
- data/lib/plurimath/math/function/over.rb +6 -0
- data/lib/plurimath/math/function/overset.rb +46 -1
- data/lib/plurimath/math/function/phantom.rb +18 -2
- data/lib/plurimath/math/function/power.rb +37 -0
- data/lib/plurimath/math/function/power_base.rb +45 -18
- data/lib/plurimath/math/function/prod.rb +46 -0
- data/lib/plurimath/math/function/right.rb +4 -0
- data/lib/plurimath/math/function/root.rb +9 -1
- data/lib/plurimath/math/function/rule.rb +4 -0
- data/lib/plurimath/math/function/sqrt.rb +7 -1
- data/lib/plurimath/math/function/stackrel.rb +6 -0
- data/lib/plurimath/math/function/substack.rb +4 -0
- data/lib/plurimath/math/function/sum.rb +45 -24
- data/lib/plurimath/math/function/table/bmatrix.rb +18 -5
- data/lib/plurimath/math/function/table/cases.rb +24 -0
- data/lib/plurimath/math/function/table/eqarray.rb +24 -0
- data/lib/plurimath/math/function/table/matrix.rb +23 -3
- data/lib/plurimath/math/function/table/pmatrix.rb +4 -0
- data/lib/plurimath/math/function/table/vmatrix.rb +10 -0
- data/lib/plurimath/math/function/table.rb +58 -7
- data/lib/plurimath/math/function/td.rb +9 -0
- data/lib/plurimath/math/function/ternary_function.rb +14 -1
- data/lib/plurimath/math/function/text.rb +6 -0
- data/lib/plurimath/math/function/tilde.rb +4 -0
- data/lib/plurimath/math/function/tr.rb +9 -0
- data/lib/plurimath/math/function/ubrace.rb +5 -0
- data/lib/plurimath/math/function/ul.rb +4 -0
- data/lib/plurimath/math/function/unary_function.rb +4 -0
- data/lib/plurimath/math/function/underover.rb +14 -0
- data/lib/plurimath/math/function/underset.rb +49 -1
- data/lib/plurimath/math/function/vec.rb +4 -0
- data/lib/plurimath/math/number.rb +33 -3
- data/lib/plurimath/math/symbol.rb +68 -3
- data/lib/plurimath/math.rb +3 -2
- data/lib/plurimath/mathml/constants.rb +16 -0
- data/lib/plurimath/mathml/parser.rb +42 -2
- data/lib/plurimath/mathml/transform.rb +80 -29
- data/lib/plurimath/omml/parser.rb +8 -0
- data/lib/plurimath/omml/transform.rb +29 -26
- data/lib/plurimath/unicode_math/constants.rb +1015 -0
- data/lib/plurimath/unicode_math/parse.rb +233 -0
- data/lib/plurimath/unicode_math/parser.rb +58 -0
- data/lib/plurimath/unicode_math/parsing_rules/absence_rules.rb +138 -0
- data/lib/plurimath/unicode_math/parsing_rules/common_rules.rb +114 -0
- data/lib/plurimath/unicode_math/parsing_rules/constants_rules.rb +102 -0
- data/lib/plurimath/unicode_math/parsing_rules/helper.rb +19 -0
- data/lib/plurimath/unicode_math/parsing_rules/masked.rb +62 -0
- data/lib/plurimath/unicode_math/parsing_rules/sub_sup.rb +254 -0
- data/lib/plurimath/unicode_math/transform.rb +3831 -0
- data/lib/plurimath/{unicode.rb → unicode_math.rb} +2 -2
- data/lib/plurimath/unitsml.rb +14 -1
- data/lib/plurimath/utility.rb +346 -11
- data/lib/plurimath/version.rb +1 -1
- data/lib/plurimath/xml_engine/oga.rb +5 -0
- data/lib/plurimath/xml_engine/ox.rb +5 -0
- metadata +23 -3
@@ -15,7 +15,7 @@ module Plurimath
|
|
15
15
|
Utility.update_nodes(
|
16
16
|
Utility.ox_element(
|
17
17
|
"mstyle",
|
18
|
-
attributes: { mathvariant:
|
18
|
+
attributes: { mathvariant: font_family(mathml: true) },
|
19
19
|
),
|
20
20
|
[first_value],
|
21
21
|
)
|
@@ -33,6 +33,10 @@ module Plurimath
|
|
33
33
|
parameter_one&.to_latex
|
34
34
|
end
|
35
35
|
|
36
|
+
def to_unicodemath
|
37
|
+
"#{font_family(unicode: true)}#{parameter_one&.to_unicodemath}"
|
38
|
+
end
|
39
|
+
|
36
40
|
def validate_function_formula
|
37
41
|
true
|
38
42
|
end
|
@@ -82,7 +86,7 @@ module Plurimath
|
|
82
86
|
new_spacing = gsub_spacing(spacing, last)
|
83
87
|
new_arr = [
|
84
88
|
"#{spacing}\"#{dump_mathml(self)}\" function apply\n",
|
85
|
-
"#{new_spacing}|_ \"#{
|
89
|
+
"#{new_spacing}|_ \"#{font_family(mathml: true)}\" font family\n",
|
86
90
|
]
|
87
91
|
mathml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ ", array: new_arr })
|
88
92
|
new_arr
|
@@ -92,15 +96,28 @@ module Plurimath
|
|
92
96
|
new_spacing = gsub_spacing(spacing, last)
|
93
97
|
new_arr = [
|
94
98
|
"#{spacing}\"#{dump_omml(self, display_style)}\" function apply\n",
|
95
|
-
"#{new_spacing}|_ \"#{
|
99
|
+
"#{new_spacing}|_ \"#{font_family(omml: true)}\" font family\n",
|
96
100
|
]
|
97
101
|
omml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ ", array: new_arr, display_style: display_style })
|
98
102
|
new_arr
|
99
103
|
end
|
100
104
|
|
101
|
-
def
|
102
|
-
fonts =
|
103
|
-
|
105
|
+
def font_family(unicode: false, omml: false, mathml: false)
|
106
|
+
fonts = font_classes
|
107
|
+
fonts = font_classes(parameter_to_class) if fonts.empty?
|
108
|
+
supported_fonts(fonts, unicode: unicode, omml: omml, mathml: mathml)
|
109
|
+
end
|
110
|
+
|
111
|
+
def supported_fonts(fonts_array = [], unicode: false, omml: false, mathml: false)
|
112
|
+
if unicode
|
113
|
+
font = UnicodeMath::Constants::FONTS_CLASSES.find { |value| fonts_array.include?(value) }
|
114
|
+
return "\\#{font}" if font
|
115
|
+
end
|
116
|
+
return Omml::Parser::SUPPORTED_FONTS.values.find { |value| fonts_array.include?(value) } if omml
|
117
|
+
if mathml
|
118
|
+
Mathml::Constants::SUPPORTED_FONT_STYLES.find { |string, object| fonts_array.include?(string.to_s) }&.first ||
|
119
|
+
parameter_two
|
120
|
+
end
|
104
121
|
end
|
105
122
|
|
106
123
|
def line_breaking(obj)
|
@@ -114,6 +131,14 @@ module Plurimath
|
|
114
131
|
)
|
115
132
|
)
|
116
133
|
end
|
134
|
+
|
135
|
+
def font_classes(object = self)
|
136
|
+
Utility::FONT_STYLES.select { |_font, font_class| font_class == object.class }.keys.map(&:to_s)
|
137
|
+
end
|
138
|
+
|
139
|
+
def parameter_to_class
|
140
|
+
Utility::FONT_STYLES.select { |font, _font_class| font == parameter_two.to_sym }&.values&.first&.new('')
|
141
|
+
end
|
117
142
|
end
|
118
143
|
end
|
119
144
|
end
|
@@ -6,12 +6,25 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Frac < BinaryFunction
|
9
|
+
attr_accessor :options
|
9
10
|
FUNCTION = {
|
10
11
|
name: "fraction",
|
11
12
|
first_value: "numerator",
|
12
13
|
second_value: "denominator",
|
13
14
|
}.freeze
|
14
15
|
|
16
|
+
def initialize(parameter_one = nil,
|
17
|
+
parameter_two = nil,
|
18
|
+
options = {})
|
19
|
+
super(parameter_one, parameter_two)
|
20
|
+
@options = options if options && !options&.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
def ==(object)
|
24
|
+
super(object) &&
|
25
|
+
object.options == options
|
26
|
+
end
|
27
|
+
|
15
28
|
def to_asciimath
|
16
29
|
first_value = "(#{parameter_one&.to_asciimath})" if parameter_one
|
17
30
|
second_value = "(#{parameter_two&.to_asciimath})" if parameter_two
|
@@ -19,12 +32,14 @@ module Plurimath
|
|
19
32
|
end
|
20
33
|
|
21
34
|
def to_mathml_without_math_tag
|
22
|
-
tag_name = hide_function_name ? "
|
35
|
+
tag_name = hide_function_name ? "mrow" : "mfrac"
|
23
36
|
mathml_value = [
|
24
37
|
parameter_one&.to_mathml_without_math_tag,
|
25
38
|
parameter_two&.to_mathml_without_math_tag,
|
26
39
|
]
|
27
|
-
|
40
|
+
frac_tag = ox_element(tag_name)
|
41
|
+
frac_tag.attributes.merge!(options) if tag_name == "mfrac" && options
|
42
|
+
Utility.update_nodes(frac_tag, mathml_value)
|
28
43
|
end
|
29
44
|
|
30
45
|
def to_latex
|
@@ -35,26 +50,35 @@ module Plurimath
|
|
35
50
|
|
36
51
|
def to_omml_without_math_tag(display_style)
|
37
52
|
f_element = Utility.ox_element("f", namespace: "m")
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
omml_parameter(parameter_one, display_style, tag_name: "num"),
|
46
|
-
omml_parameter(parameter_two, display_style, tag_name: "den"),
|
47
|
-
],
|
48
|
-
),
|
53
|
+
Utility.update_nodes(
|
54
|
+
f_element,
|
55
|
+
[
|
56
|
+
fpr_element,
|
57
|
+
omml_parameter(parameter_one, display_style, tag_name: "num"),
|
58
|
+
omml_parameter(parameter_two, display_style, tag_name: "den"),
|
59
|
+
],
|
49
60
|
)
|
50
61
|
end
|
51
62
|
|
63
|
+
def to_unicodemath
|
64
|
+
return unicodemath_fraction if options&.dig(:unicodemath_fraction)
|
65
|
+
|
66
|
+
first_value = unicodemath_parens(parameter_one) if parameter_one
|
67
|
+
second_value = unicodemath_parens(parameter_two) if parameter_two
|
68
|
+
return "#{first_value}/#{second_value}" unless options
|
69
|
+
|
70
|
+
return "#{first_value}¦#{second_value}" if options && options.key?(:linethickness)
|
71
|
+
return "#{parameter_one.to_unicodemath}⊘#{parameter_two.to_unicodemath}" if options && options.key?(:displaystyle)
|
72
|
+
"#{first_value}∕#{second_value}" if options && options.key?(:ldiv)
|
73
|
+
end
|
74
|
+
|
52
75
|
def line_breaking(obj)
|
53
76
|
parameter_one&.line_breaking(obj)
|
54
77
|
if obj.value_exist?
|
55
|
-
|
78
|
+
frac = self.class.new(Utility.filter_values(obj.value), parameter_two)
|
79
|
+
frac.hide_function_name = true
|
80
|
+
obj.update(frac)
|
56
81
|
self.parameter_two = nil
|
57
|
-
self.hide_function_name = true
|
58
82
|
return
|
59
83
|
end
|
60
84
|
|
@@ -65,6 +89,36 @@ module Plurimath
|
|
65
89
|
obj.update(frac)
|
66
90
|
end
|
67
91
|
end
|
92
|
+
|
93
|
+
def choose_frac
|
94
|
+
first_value = unicodemath_parens(parameter_one) if parameter_one
|
95
|
+
second_value = unicodemath_parens(parameter_two) if parameter_two
|
96
|
+
"#{first_value}⒞#{second_value}"
|
97
|
+
end
|
98
|
+
|
99
|
+
protected
|
100
|
+
|
101
|
+
def fpr_element
|
102
|
+
fpr_element = Utility.ox_element("fPr", namespace: "m")
|
103
|
+
if options
|
104
|
+
attributes = { "m:val": attr_value }
|
105
|
+
fpr_element << Utility.ox_element("type", namespace: "m", attributes: attributes)
|
106
|
+
end
|
107
|
+
fpr_element << Utility.pr_element("ctrl", true, namespace: "m")
|
108
|
+
end
|
109
|
+
|
110
|
+
def attr_value
|
111
|
+
if options[:linethickness] == "0"
|
112
|
+
"noBar"
|
113
|
+
else
|
114
|
+
options[:bevelled] == 'true' ? 'skw' : "bar"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def unicodemath_fraction
|
119
|
+
frac_array = [parameter_one.value.to_i, parameter_two.value.to_i]
|
120
|
+
UnicodeMath::Constants::UNICODE_FRACTIONS.key(frac_array)
|
121
|
+
end
|
68
122
|
end
|
69
123
|
end
|
70
124
|
end
|
@@ -49,6 +49,36 @@ module Plurimath
|
|
49
49
|
self.parameter_two = nil
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
def to_unicodemath
|
54
|
+
"inf#{sub_value}#{sup_value}"
|
55
|
+
end
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
def sup_value
|
60
|
+
return unless parameter_two
|
61
|
+
|
62
|
+
if parameter_two&.mini_sized? || prime_unicode?(parameter_two)
|
63
|
+
parameter_two.to_unicodemath
|
64
|
+
elsif parameter_two.is_a?(Math::Function::Power)
|
65
|
+
"^#{parameter_two.to_unicodemath}"
|
66
|
+
else
|
67
|
+
"^#{unicodemath_parens(parameter_two)}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def sub_value
|
72
|
+
return unless parameter_one
|
73
|
+
|
74
|
+
if parameter_one&.mini_sized?
|
75
|
+
parameter_one.to_unicodemath
|
76
|
+
elsif parameter_one.is_a?(Math::Function::Base)
|
77
|
+
"_#{parameter_one.to_unicodemath}"
|
78
|
+
else
|
79
|
+
"_#{unicodemath_parens(parameter_one)}"
|
80
|
+
end
|
81
|
+
end
|
52
82
|
end
|
53
83
|
end
|
54
84
|
end
|
@@ -6,12 +6,25 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Int < TernaryFunction
|
9
|
+
attr_accessor :options
|
9
10
|
FUNCTION = {
|
10
11
|
name: "integral",
|
11
12
|
first_value: "lower limit",
|
12
13
|
second_value: "upper limit",
|
13
14
|
third_value: "integrand"
|
14
|
-
}
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
def initialize(parameter_one = nil,
|
18
|
+
parameter_two = nil,
|
19
|
+
parameter_three = nil,
|
20
|
+
options = {})
|
21
|
+
super(parameter_one, parameter_two, parameter_three)
|
22
|
+
@options = options unless options&.empty?
|
23
|
+
end
|
24
|
+
|
25
|
+
def ==(object)
|
26
|
+
super(object) && object.options == options
|
27
|
+
end
|
15
28
|
|
16
29
|
def to_asciimath
|
17
30
|
first_value = "_#{wrapped(parameter_one)}" if parameter_one
|
@@ -62,6 +75,13 @@ module Plurimath
|
|
62
75
|
end
|
63
76
|
end
|
64
77
|
|
78
|
+
def to_unicodemath
|
79
|
+
first_value = sub_value if parameter_one
|
80
|
+
second_value = sup_value if parameter_two
|
81
|
+
mask = options&.dig(:mask) if options&.key?(:mask)
|
82
|
+
"∫#{mask}#{first_value}#{second_value}#{naryand_value(parameter_three)}"
|
83
|
+
end
|
84
|
+
|
65
85
|
def line_breaking(obj)
|
66
86
|
parameter_one&.line_breaking(obj)
|
67
87
|
if obj.value_exist?
|
@@ -88,6 +108,32 @@ module Plurimath
|
|
88
108
|
omml_parameter(parameter_three, display_style, tag_name: "e"),
|
89
109
|
]
|
90
110
|
end
|
111
|
+
|
112
|
+
def is_nary_function?
|
113
|
+
true
|
114
|
+
end
|
115
|
+
|
116
|
+
protected
|
117
|
+
|
118
|
+
def sup_value
|
119
|
+
if parameter_two&.mini_sized? || prime_unicode?(parameter_two)
|
120
|
+
parameter_two.to_unicodemath
|
121
|
+
elsif parameter_two.is_a?(Math::Function::Power)
|
122
|
+
"^#{parameter_two.to_unicodemath}"
|
123
|
+
else
|
124
|
+
"^#{unicodemath_parens(parameter_two)}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def sub_value
|
129
|
+
if parameter_one&.mini_sized?
|
130
|
+
parameter_one.to_unicodemath
|
131
|
+
elsif parameter_one.is_a?(Math::Function::Base)
|
132
|
+
"_#{parameter_one.to_unicodemath}"
|
133
|
+
else
|
134
|
+
"_#{unicodemath_parens(parameter_one)}"
|
135
|
+
end
|
136
|
+
end
|
91
137
|
end
|
92
138
|
end
|
93
139
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Intent < BinaryFunction
|
9
|
+
def to_mathml_without_math_tag
|
10
|
+
first_value = parameter_one.to_mathml_without_math_tag
|
11
|
+
first_value.attributes[:intent] = Utility.html_entity_to_unicode(parameter_two.value)
|
12
|
+
first_value
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_unicodemath
|
16
|
+
first_value = "(#{parameter_two.to_unicodemath}#{parameter_one.to_unicodemath})" if parameter_one || parameter_two
|
17
|
+
"ⓘ#{first_value}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -49,6 +49,12 @@ module Plurimath
|
|
49
49
|
underover(display_style)
|
50
50
|
end
|
51
51
|
|
52
|
+
def to_unicodemath
|
53
|
+
first_value = "_#{unicodemath_parens(parameter_one)}" if parameter_one
|
54
|
+
second_value = "^#{unicodemath_parens(parameter_two)}" if parameter_two
|
55
|
+
"lim#{first_value}#{second_value}"
|
56
|
+
end
|
57
|
+
|
52
58
|
def line_breaking(obj)
|
53
59
|
parameter_one.line_breaking(obj)
|
54
60
|
if obj.value_exist?
|
@@ -34,6 +34,10 @@ module Plurimath
|
|
34
34
|
underover(display_style)
|
35
35
|
end
|
36
36
|
|
37
|
+
def to_unicodemath
|
38
|
+
"#{parameter_one&.to_unicodemath}#{sup_value}#{sub_value}"
|
39
|
+
end
|
40
|
+
|
37
41
|
def line_breaking(obj)
|
38
42
|
parameter_one&.line_breaking(obj)
|
39
43
|
if obj.value_exist?
|
@@ -49,6 +53,30 @@ module Plurimath
|
|
49
53
|
self.parameter_three = nil
|
50
54
|
end
|
51
55
|
end
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
def sup_value
|
60
|
+
return unless parameter_three
|
61
|
+
|
62
|
+
if parameter_three.is_a?(Math::Function::Power)
|
63
|
+
"┴#{parameter_three.to_unicodemath}"
|
64
|
+
elsif parameter_one.is_a?(Math::Function::Power) && parameter_one&.prime_unicode?(parameter_one&.parameter_two)
|
65
|
+
"┴#{parameter_three.to_unicodemath}"
|
66
|
+
else
|
67
|
+
"┴#{unicodemath_parens(parameter_three)}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def sub_value
|
72
|
+
return unless parameter_two
|
73
|
+
|
74
|
+
if parameter_two.is_a?(Math::Function::Base)
|
75
|
+
"┬#{parameter_two.to_unicodemath}"
|
76
|
+
else
|
77
|
+
"┬#{unicodemath_parens(parameter_two)}"
|
78
|
+
end
|
79
|
+
end
|
52
80
|
end
|
53
81
|
end
|
54
82
|
end
|
@@ -35,7 +35,7 @@ module Plurimath
|
|
35
35
|
|
36
36
|
ssubsup = Utility.ox_element("sSubSup", namespace: "m")
|
37
37
|
ssubsuppr = Utility.ox_element("sSubSupPr", namespace: "m")
|
38
|
-
ssubsuppr <<
|
38
|
+
ssubsuppr << Utility.pr_element("ctrl", true, namespace: "m")
|
39
39
|
Utility.update_nodes(
|
40
40
|
ssubsup,
|
41
41
|
[
|
@@ -63,6 +63,12 @@ module Plurimath
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
def to_unicodemath
|
67
|
+
first_value = sub_value if parameter_one
|
68
|
+
second_value = sup_value if parameter_two
|
69
|
+
"log#{first_value}#{second_value}"
|
70
|
+
end
|
71
|
+
|
66
72
|
def line_breaking(obj)
|
67
73
|
parameter_one&.line_breaking(obj)
|
68
74
|
if obj.value_exist?
|
@@ -82,25 +88,6 @@ module Plurimath
|
|
82
88
|
e_tag << rpr_tag
|
83
89
|
end
|
84
90
|
|
85
|
-
def hide_tags(nar)
|
86
|
-
attr = { "m:val": "1" }
|
87
|
-
if parameter_one.nil?
|
88
|
-
nar << Utility.ox_element(
|
89
|
-
"subHide",
|
90
|
-
namespace: "m",
|
91
|
-
attributes: attr,
|
92
|
-
)
|
93
|
-
end
|
94
|
-
if parameter_two.nil?
|
95
|
-
nar << Utility.ox_element(
|
96
|
-
"supHide",
|
97
|
-
namespace: "m",
|
98
|
-
attributes: attr,
|
99
|
-
)
|
100
|
-
end
|
101
|
-
nar
|
102
|
-
end
|
103
|
-
|
104
91
|
def rpr_tag
|
105
92
|
sty_atrs = { "m:val": "p" }
|
106
93
|
sty_tag = Utility.ox_element("sty", attributes: sty_atrs, namespace: "m")
|
@@ -109,6 +96,26 @@ module Plurimath
|
|
109
96
|
t_tag = (Utility.ox_element("t", namespace: "m") << "log")
|
110
97
|
Utility.update_nodes(r_tag, [rpr_tag, t_tag])
|
111
98
|
end
|
99
|
+
|
100
|
+
def sup_value
|
101
|
+
if parameter_two&.mini_sized? || prime_unicode?(parameter_two)
|
102
|
+
parameter_two.to_unicodemath
|
103
|
+
elsif parameter_two.is_a?(Math::Function::Power)
|
104
|
+
"^#{parameter_two.to_unicodemath}"
|
105
|
+
else
|
106
|
+
"^#{unicodemath_parens(parameter_two)}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def sub_value
|
111
|
+
if parameter_one&.mini_sized?
|
112
|
+
parameter_one.to_unicodemath
|
113
|
+
elsif parameter_one.is_a?(Math::Function::Base)
|
114
|
+
"_#{parameter_one.to_unicodemath}"
|
115
|
+
else
|
116
|
+
"_#{unicodemath_parens(parameter_one)}"
|
117
|
+
end
|
118
|
+
end
|
112
119
|
end
|
113
120
|
end
|
114
121
|
end
|
@@ -11,6 +11,18 @@ module Plurimath
|
|
11
11
|
first_value: "enclosure type",
|
12
12
|
second_value: "expression",
|
13
13
|
}.freeze
|
14
|
+
FOUR_SIDED_NOTATIONS = {
|
15
|
+
top: "hideTop",
|
16
|
+
bottom: "hideBot",
|
17
|
+
left: "hideLeft",
|
18
|
+
right: "hideRight",
|
19
|
+
}
|
20
|
+
STRIKES_NOTATIONS = {
|
21
|
+
horizontalstrike: "strikeH",
|
22
|
+
verticalstrike: "strikeV",
|
23
|
+
updiagonalstrike: "strikeBLTR",
|
24
|
+
downdiagonalstrike: "strikeTLBR",
|
25
|
+
}
|
14
26
|
|
15
27
|
def to_asciimath
|
16
28
|
parameter_two&.to_asciimath
|
@@ -18,7 +30,7 @@ module Plurimath
|
|
18
30
|
|
19
31
|
def to_mathml_without_math_tag
|
20
32
|
attributes = { notation: parameter_one }
|
21
|
-
menclose =
|
33
|
+
menclose = ox_element("menclose", attributes: attributes)
|
22
34
|
menclose << parameter_two.to_mathml_without_math_tag if parameter_two
|
23
35
|
menclose
|
24
36
|
end
|
@@ -33,18 +45,75 @@ module Plurimath
|
|
33
45
|
end
|
34
46
|
|
35
47
|
def to_omml_without_math_tag(display_style)
|
36
|
-
borderbox =
|
37
|
-
borderpr = Utility.ox_element("borderBoxPr", namespace: "m")
|
38
|
-
borderpr << Utility.pr_element("ctrl", true, namespace: "m")
|
48
|
+
borderbox = ox_element("borderBox", namespace: "m")
|
39
49
|
Utility.update_nodes(
|
40
50
|
borderbox,
|
41
51
|
[
|
42
|
-
|
52
|
+
borderboxpr,
|
43
53
|
omml_parameter(parameter_two, display_style, tag_name: "e"),
|
44
54
|
],
|
45
55
|
)
|
46
56
|
[borderbox]
|
47
57
|
end
|
58
|
+
|
59
|
+
def to_unicodemath
|
60
|
+
if unicode_symbol?
|
61
|
+
"#{unicode_symbol}#{unicodemath_parens(parameter_two)}"
|
62
|
+
elsif masked_class?
|
63
|
+
first_value = Utility.notations_to_mask(parameter_one) if parameter_one
|
64
|
+
second_value = parameter_two&.to_unicodemath if parameter_two
|
65
|
+
"▭(#{first_value}&#{second_value})"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
protected
|
70
|
+
|
71
|
+
def borderboxpr
|
72
|
+
return if %w[box circle roundedbox].include?(parameter_one)
|
73
|
+
|
74
|
+
borderpr = ox_element("borderBoxPr", namespace: "m")
|
75
|
+
four_sided_notations(borderpr)
|
76
|
+
strikes_notations(borderpr)
|
77
|
+
borderpr
|
78
|
+
end
|
79
|
+
|
80
|
+
def four_sided_notations(borderpr)
|
81
|
+
return if %w[box circle roundedbox].any? { |value| parameter_one.include?(value) }
|
82
|
+
|
83
|
+
FOUR_SIDED_NOTATIONS.each do |side, rep|
|
84
|
+
border_ox_element(rep, !parameter_one.include?(side.to_s), borderpr)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def strikes_notations(borderpr)
|
89
|
+
STRIKES_NOTATIONS.each do |strike, rep|
|
90
|
+
border_ox_element(rep, parameter_one.include?(strike.to_s), borderpr)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def border_ox_element(tag_name, condition, borderpr)
|
95
|
+
return unless condition
|
96
|
+
|
97
|
+
borderpr << ox_element(
|
98
|
+
tag_name,
|
99
|
+
namespace: "m",
|
100
|
+
attributes: { "m:val": "on" },
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
def masked_class?
|
105
|
+
Utility::MASK_CLASSES.values.any? { |mask| parameter_one.include?(mask) }
|
106
|
+
end
|
107
|
+
|
108
|
+
def unicode_symbol
|
109
|
+
class_name = Utility::UNICODEMATH_MENCLOSE_FUNCTIONS.key(parameter_one)
|
110
|
+
UnicodeMath::Constants::UNARY_ARG_FUNCTIONS[class_name] ||
|
111
|
+
UnicodeMath::Constants::UNARY_SYMBOLS[class_name]
|
112
|
+
end
|
113
|
+
|
114
|
+
def unicode_symbol?
|
115
|
+
Utility::UNICODEMATH_MENCLOSE_FUNCTIONS.value?(parameter_one)
|
116
|
+
end
|
48
117
|
end
|
49
118
|
end
|
50
119
|
end
|