plurimath 0.10.0 → 0.10.2
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/.rspec-opal +1 -1
- data/.rubocop.yml +9 -5
- data/.rubocop_todo.yml +0 -0
- data/Gemfile +7 -5
- data/README.adoc +57 -1
- data/Rakefile +11 -0
- data/lib/plurimath/asciimath/parse.rb +0 -1
- data/lib/plurimath/asciimath/parser.rb +0 -3
- data/lib/plurimath/asciimath.rb +5 -0
- data/lib/plurimath/cli.rb +28 -1
- data/lib/plurimath/errors.rb +0 -4
- data/lib/plurimath/formatter/numbers.rb +12 -0
- data/lib/plurimath/formatter/numeric_formatter.rb +4 -1
- data/lib/plurimath/formatter/standard.rb +0 -1
- data/lib/plurimath/formatter.rb +6 -9
- data/lib/plurimath/html/parse.rb +0 -1
- data/lib/plurimath/html/parser.rb +0 -3
- data/lib/plurimath/html.rb +5 -0
- data/lib/plurimath/latex/parse.rb +0 -1
- data/lib/plurimath/latex/parser.rb +2 -5
- data/lib/plurimath/latex.rb +5 -0
- data/lib/plurimath/math/core.rb +6 -2
- data/lib/plurimath/math/formula/mrow.rb +2 -41
- data/lib/plurimath/math/formula/mstyle.rb +6 -0
- data/lib/plurimath/math/formula.rb +59 -301
- data/lib/plurimath/math/function/abs.rb +0 -1
- data/lib/plurimath/math/function/arccos.rb +0 -1
- data/lib/plurimath/math/function/arcsin.rb +0 -1
- data/lib/plurimath/math/function/arctan.rb +0 -1
- data/lib/plurimath/math/function/arg.rb +0 -1
- data/lib/plurimath/math/function/bar.rb +0 -1
- data/lib/plurimath/math/function/base.rb +0 -3
- data/lib/plurimath/math/function/binary_function.rb +5 -3
- data/lib/plurimath/math/function/cancel.rb +0 -1
- data/lib/plurimath/math/function/ceil.rb +0 -1
- data/lib/plurimath/math/function/color.rb +0 -1
- data/lib/plurimath/math/function/cos.rb +0 -1
- data/lib/plurimath/math/function/cosh.rb +0 -1
- data/lib/plurimath/math/function/cot.rb +0 -1
- data/lib/plurimath/math/function/coth.rb +0 -1
- data/lib/plurimath/math/function/csc.rb +0 -1
- data/lib/plurimath/math/function/csch.rb +0 -1
- data/lib/plurimath/math/function/ddot.rb +0 -1
- data/lib/plurimath/math/function/deg.rb +0 -1
- data/lib/plurimath/math/function/det.rb +0 -1
- data/lib/plurimath/math/function/dim.rb +0 -1
- data/lib/plurimath/math/function/dot.rb +0 -1
- data/lib/plurimath/math/function/exp.rb +0 -1
- data/lib/plurimath/math/function/fenced.rb +1 -197
- data/lib/plurimath/math/function/floor.rb +0 -1
- data/lib/plurimath/math/function/font_style/bold-fraktur.rb +0 -1
- data/lib/plurimath/math/function/font_style/bold-italic.rb +0 -1
- data/lib/plurimath/math/function/font_style/bold-sans-serif.rb +0 -1
- data/lib/plurimath/math/function/font_style/bold-script.rb +0 -1
- data/lib/plurimath/math/function/font_style/bold.rb +0 -1
- data/lib/plurimath/math/function/font_style/double_struck.rb +0 -1
- data/lib/plurimath/math/function/font_style/fraktur.rb +0 -1
- data/lib/plurimath/math/function/font_style/italic.rb +0 -1
- data/lib/plurimath/math/function/font_style/monospace.rb +0 -1
- data/lib/plurimath/math/function/font_style/normal.rb +0 -1
- data/lib/plurimath/math/function/font_style/sans-serif-bold-italic.rb +0 -1
- data/lib/plurimath/math/function/font_style/sans-serif-italic.rb +0 -1
- data/lib/plurimath/math/function/font_style/sans-serif.rb +0 -1
- data/lib/plurimath/math/function/font_style/script.rb +0 -1
- data/lib/plurimath/math/function/font_style.rb +29 -2
- data/lib/plurimath/math/function/frac.rb +0 -3
- data/lib/plurimath/math/function/gcd.rb +0 -1
- data/lib/plurimath/math/function/glb.rb +0 -1
- data/lib/plurimath/math/function/hat.rb +0 -1
- data/lib/plurimath/math/function/hom.rb +0 -1
- data/lib/plurimath/math/function/inf.rb +1 -2
- data/lib/plurimath/math/function/int.rb +2 -3
- data/lib/plurimath/math/function/intent.rb +0 -1
- data/lib/plurimath/math/function/ker.rb +0 -1
- data/lib/plurimath/math/function/lcm.rb +0 -1
- data/lib/plurimath/math/function/left.rb +0 -1
- data/lib/plurimath/math/function/lg.rb +0 -1
- data/lib/plurimath/math/function/lim.rb +1 -2
- data/lib/plurimath/math/function/liminf.rb +0 -1
- data/lib/plurimath/math/function/limits.rb +0 -1
- data/lib/plurimath/math/function/limsup.rb +0 -1
- data/lib/plurimath/math/function/linebreak.rb +0 -1
- data/lib/plurimath/math/function/ln.rb +0 -1
- data/lib/plurimath/math/function/log.rb +1 -2
- data/lib/plurimath/math/function/longdiv.rb +0 -3
- data/lib/plurimath/math/function/lub.rb +0 -1
- data/lib/plurimath/math/function/max.rb +0 -1
- data/lib/plurimath/math/function/mbox.rb +0 -1
- data/lib/plurimath/math/function/menclose.rb +0 -3
- data/lib/plurimath/math/function/merror.rb +0 -3
- data/lib/plurimath/math/function/mglyph.rb +0 -3
- data/lib/plurimath/math/function/min.rb +0 -1
- data/lib/plurimath/math/function/mlabeledtr.rb +0 -20
- data/lib/plurimath/math/function/mod.rb +0 -1
- data/lib/plurimath/math/function/mpadded.rb +0 -3
- data/lib/plurimath/math/function/ms.rb +1 -77
- data/lib/plurimath/math/function/msgroup.rb +0 -27
- data/lib/plurimath/math/function/msline.rb +0 -3
- data/lib/plurimath/math/function/multiscript.rb +0 -14
- data/lib/plurimath/math/function/nary.rb +4 -0
- data/lib/plurimath/math/function/none.rb +1 -4
- data/lib/plurimath/math/function/norm.rb +0 -1
- data/lib/plurimath/math/function/obrace.rb +0 -1
- data/lib/plurimath/math/function/oint.rb +2 -3
- data/lib/plurimath/math/function/over.rb +0 -3
- data/lib/plurimath/math/function/overset.rb +3 -3
- data/lib/plurimath/math/function/phantom.rb +0 -3
- data/lib/plurimath/math/function/power.rb +0 -3
- data/lib/plurimath/math/function/power_base.rb +0 -3
- data/lib/plurimath/math/function/prod.rb +2 -3
- data/lib/plurimath/math/function/right.rb +0 -1
- data/lib/plurimath/math/function/root.rb +0 -3
- data/lib/plurimath/math/function/rule.rb +0 -1
- data/lib/plurimath/math/function/scarries.rb +0 -3
- data/lib/plurimath/math/function/scarry.rb +22 -0
- data/lib/plurimath/math/function/sec.rb +0 -1
- data/lib/plurimath/math/function/sech.rb +0 -1
- data/lib/plurimath/math/function/semantics.rb +0 -15
- data/lib/plurimath/math/function/sin.rb +0 -1
- data/lib/plurimath/math/function/sinh.rb +0 -1
- data/lib/plurimath/math/function/sqrt.rb +0 -3
- data/lib/plurimath/math/function/stackrel.rb +0 -3
- data/lib/plurimath/math/function/substack.rb +0 -1
- data/lib/plurimath/math/function/sum.rb +2 -3
- data/lib/plurimath/math/function/sup.rb +0 -1
- data/lib/plurimath/math/function/table/align.rb +0 -1
- data/lib/plurimath/math/function/table/array.rb +0 -1
- data/lib/plurimath/math/function/table/bmatrix.rb +0 -1
- data/lib/plurimath/math/function/table/cases.rb +0 -1
- data/lib/plurimath/math/function/table/eqarray.rb +0 -1
- data/lib/plurimath/math/function/table/matrix.rb +0 -1
- data/lib/plurimath/math/function/table/multline.rb +0 -1
- data/lib/plurimath/math/function/table/pmatrix.rb +0 -1
- data/lib/plurimath/math/function/table/split.rb +0 -1
- data/lib/plurimath/math/function/table/vmatrix.rb +0 -1
- data/lib/plurimath/math/function/table.rb +10 -23
- data/lib/plurimath/math/function/tan.rb +0 -1
- data/lib/plurimath/math/function/tanh.rb +0 -1
- data/lib/plurimath/math/function/td.rb +0 -4
- data/lib/plurimath/math/function/ternary_function.rb +6 -2
- data/lib/plurimath/math/function/text.rb +1 -6
- data/lib/plurimath/math/function/tilde.rb +4 -1
- data/lib/plurimath/math/function/tr.rb +0 -13
- data/lib/plurimath/math/function/ubrace.rb +0 -1
- data/lib/plurimath/math/function/ul.rb +4 -1
- data/lib/plurimath/math/function/underover.rb +0 -3
- data/lib/plurimath/math/function/underset.rb +22 -45
- data/lib/plurimath/math/function/unitsml.rb +2 -1
- data/lib/plurimath/math/function/vec.rb +4 -1
- data/lib/plurimath/math/function.rb +107 -10
- data/lib/plurimath/math/number.rb +9 -7
- data/lib/plurimath/math/symbols/comma.rb +1 -1
- data/lib/plurimath/math/symbols/plus.rb +1 -1
- data/lib/plurimath/math/symbols/symbol.rb +17 -4
- data/lib/plurimath/math.rb +8 -26
- data/lib/plurimath/mathml/constants.rb +1 -0
- data/lib/plurimath/mathml/formula_transformation.rb +442 -0
- data/lib/plurimath/mathml/parser.rb +11 -50
- data/lib/plurimath/mathml/translator.rb +584 -0
- data/lib/plurimath/mathml/utility/formula_transformation.rb +2 -341
- data/lib/plurimath/mathml.rb +5 -0
- data/lib/plurimath/number_formatter.rb +2 -1
- data/lib/plurimath/omml/parser.rb +10 -7
- data/lib/plurimath/omml/transform.rb +17 -5
- data/lib/plurimath/omml.rb +3 -0
- data/lib/plurimath/setup/opal.rb.erb +3 -4
- data/lib/plurimath/unicode_math/parse.rb +0 -5
- data/lib/plurimath/unicode_math/parser.rb +1 -6
- data/lib/plurimath/unicode_math/parsing_rules/absence_rules.rb +0 -1
- data/lib/plurimath/unicode_math/parsing_rules/common_rules.rb +0 -1
- data/lib/plurimath/unicode_math/parsing_rules/constants_rules.rb +0 -1
- data/lib/plurimath/unicode_math/parsing_rules/masked.rb +0 -1
- data/lib/plurimath/unicode_math/parsing_rules/sub_sup.rb +0 -1
- data/lib/plurimath/unicode_math/parsing_rules.rb +14 -0
- data/lib/plurimath/unicode_math.rb +6 -0
- data/lib/plurimath/utility.rb +1 -1
- data/lib/plurimath/version.rb +1 -1
- data/lib/plurimath/xml_engine/oga.rb +6 -6
- data/lib/plurimath/xml_engine/ox_engine.rb +2 -2
- data/lib/plurimath/xml_engine.rb +2 -0
- data/lib/plurimath.rb +43 -18
- data/plurimath.gemspec +5 -4
- metadata +33 -15
- data/lib/plurimath/mathml/utility/empty_defined_methods.rb +0 -483
- data/lib/plurimath/mathml/utility.rb +0 -369
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../../mathml/utility"
|
|
4
|
-
|
|
5
3
|
module Plurimath
|
|
6
4
|
module Math
|
|
7
5
|
module Function
|
|
8
6
|
class Table < Core
|
|
9
|
-
|
|
7
|
+
autoload :Align, "#{__dir__}/table/align"
|
|
8
|
+
autoload :Array, "#{__dir__}/table/array"
|
|
9
|
+
autoload :Bmatrix, "#{__dir__}/table/bmatrix"
|
|
10
|
+
autoload :Cases, "#{__dir__}/table/cases"
|
|
11
|
+
autoload :Eqarray, "#{__dir__}/table/eqarray"
|
|
12
|
+
autoload :Matrix, "#{__dir__}/table/matrix"
|
|
13
|
+
autoload :Multline, "#{__dir__}/table/multline"
|
|
14
|
+
autoload :Pmatrix, "#{__dir__}/table/pmatrix"
|
|
15
|
+
autoload :Split, "#{__dir__}/table/split"
|
|
16
|
+
autoload :Vmatrix, "#{__dir__}/table/vmatrix"
|
|
10
17
|
|
|
11
18
|
attr_accessor :value, :open_paren, :close_paren, :options
|
|
12
19
|
|
|
@@ -141,26 +148,6 @@ module Plurimath
|
|
|
141
148
|
}
|
|
142
149
|
end
|
|
143
150
|
|
|
144
|
-
def mtr_value=(value)
|
|
145
|
-
return if value.nil? || value.empty?
|
|
146
|
-
|
|
147
|
-
self.value = replace_order_with_value(
|
|
148
|
-
clear_temp_order,
|
|
149
|
-
update_temp_mathml_values(value),
|
|
150
|
-
"mtr"
|
|
151
|
-
)
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
def mlabeledtr_value=(value)
|
|
155
|
-
return if value.nil? || value.empty?
|
|
156
|
-
|
|
157
|
-
self.value = replace_order_with_value(
|
|
158
|
-
clear_temp_order,
|
|
159
|
-
update_temp_mathml_values(value),
|
|
160
|
-
"mlabeledtr"
|
|
161
|
-
)
|
|
162
|
-
end
|
|
163
|
-
|
|
164
151
|
def frame=(value)
|
|
165
152
|
return if value.nil? || value.empty?
|
|
166
153
|
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "binary_function"
|
|
4
|
-
require_relative "../../mathml/utility"
|
|
5
3
|
|
|
6
4
|
module Plurimath
|
|
7
5
|
module Math
|
|
8
6
|
module Function
|
|
9
7
|
class Td < BinaryFunction
|
|
10
|
-
include Mathml::Utility
|
|
11
|
-
|
|
12
8
|
def initialize(parameter_one = nil, parameter_two = nil)
|
|
13
9
|
parameter_one&.delete_if { |td| td == "&" }
|
|
14
10
|
super(Array(parameter_one), parameter_two)
|
|
@@ -54,11 +54,13 @@ module Plurimath
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def any_value_exist?
|
|
57
|
-
|
|
57
|
+
parameter_one || parameter_two || parameter_three
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def all_values_exist?
|
|
61
|
-
!
|
|
61
|
+
!parameter_one.nil? &&
|
|
62
|
+
!parameter_two.nil? &&
|
|
63
|
+
!parameter_three.nil?
|
|
62
64
|
end
|
|
63
65
|
|
|
64
66
|
def to_asciimath_math_zone(spacing, last = false, _, options:)
|
|
@@ -186,6 +188,8 @@ module Plurimath
|
|
|
186
188
|
end
|
|
187
189
|
|
|
188
190
|
def underover(display_style, options:)
|
|
191
|
+
# Build Overset from source argument positions, not OMML child names,
|
|
192
|
+
# so shared under/over functions keep the same format-neutral model.
|
|
189
193
|
overset = Overset.new(parameter_one, parameter_three)
|
|
190
194
|
return overset.to_omml_without_math_tag(display_style, options: options) unless parameter_two
|
|
191
195
|
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "htmlentities"
|
|
4
|
-
require_relative "unary_function"
|
|
5
|
-
require_relative "../../mathml/utility"
|
|
6
|
-
|
|
7
3
|
module Plurimath
|
|
8
4
|
module Math
|
|
9
5
|
module Function
|
|
10
6
|
class Text < UnaryFunction
|
|
11
|
-
include Mathml::Utility
|
|
12
7
|
|
|
13
8
|
PARSER_REGEX = %r{unicode\[:(?<unicode>\w{1,})\]}.freeze
|
|
14
9
|
|
|
@@ -102,7 +97,7 @@ module Plurimath
|
|
|
102
97
|
text = text.join if text.is_a?(Array)
|
|
103
98
|
entities = HTMLEntities.new
|
|
104
99
|
symbols = Mathml::Constants::UNICODE_SYMBOLS.transform_keys(&:to_s)
|
|
105
|
-
text = entities.encode(text, :hexadecimal)
|
|
100
|
+
text = entities.encode(entities.decode(text), :hexadecimal)
|
|
106
101
|
symbols.each do |code, string|
|
|
107
102
|
text = text.gsub(code.downcase, "unicode[:#{string}]")
|
|
108
103
|
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "unary_function"
|
|
4
3
|
|
|
5
4
|
module Plurimath
|
|
6
5
|
module Math
|
|
@@ -44,6 +43,10 @@ module Plurimath
|
|
|
44
43
|
obj.update(Utility.filter_values(obj.value)) if obj.value_exist?
|
|
45
44
|
end
|
|
46
45
|
|
|
46
|
+
def accent_char
|
|
47
|
+
"˜"
|
|
48
|
+
end
|
|
49
|
+
|
|
47
50
|
protected
|
|
48
51
|
|
|
49
52
|
def acc_tag(display_style, options:)
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "unary_function"
|
|
4
|
-
require_relative "../../mathml/utility"
|
|
5
3
|
|
|
6
4
|
module Plurimath
|
|
7
5
|
module Math
|
|
8
6
|
module Function
|
|
9
7
|
class Tr < UnaryFunction
|
|
10
|
-
include Mathml::Utility
|
|
11
|
-
|
|
12
8
|
def initialize(parameter_one = [])
|
|
13
9
|
parameter_one.map!.with_index { |_, index| Td.new([]) } if parameter_one&.all?("@")
|
|
14
10
|
super(parameter_one)
|
|
@@ -97,15 +93,6 @@ module Plurimath
|
|
|
97
93
|
first_value
|
|
98
94
|
end
|
|
99
95
|
|
|
100
|
-
def mtd_value=(value)
|
|
101
|
-
return if value.nil? || value.empty?
|
|
102
|
-
|
|
103
|
-
self.parameter_one = replace_order_with_value(
|
|
104
|
-
clear_temp_order,
|
|
105
|
-
update_temp_mathml_values(value),
|
|
106
|
-
"mtd"
|
|
107
|
-
)
|
|
108
|
-
end
|
|
109
96
|
end
|
|
110
97
|
end
|
|
111
98
|
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "unary_function"
|
|
4
3
|
|
|
5
4
|
module Plurimath
|
|
6
5
|
module Math
|
|
@@ -61,6 +60,10 @@ module Plurimath
|
|
|
61
60
|
Bar.new(parameter_one, attributes)
|
|
62
61
|
end
|
|
63
62
|
|
|
63
|
+
def accent_char
|
|
64
|
+
"\u203E"
|
|
65
|
+
end
|
|
66
|
+
|
|
64
67
|
protected
|
|
65
68
|
|
|
66
69
|
def groupchr_tag(display_style, options:)
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../../mathml/utility"
|
|
4
|
-
require_relative "ternary_function"
|
|
5
3
|
|
|
6
4
|
module Plurimath
|
|
7
5
|
module Math
|
|
8
6
|
module Function
|
|
9
7
|
class Underover < TernaryFunction
|
|
10
|
-
include Mathml::Utility
|
|
11
8
|
|
|
12
9
|
FUNCTION = {
|
|
13
10
|
name: "UnderOver",
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "binary_function"
|
|
4
|
-
require_relative "../../mathml/utility"
|
|
5
3
|
|
|
6
4
|
module Plurimath
|
|
7
5
|
module Math
|
|
8
6
|
module Function
|
|
9
7
|
class Underset < BinaryFunction
|
|
10
|
-
include Mathml::Utility
|
|
11
|
-
|
|
12
8
|
attr_accessor :options
|
|
13
9
|
|
|
14
10
|
FUNCTION = {
|
|
@@ -22,14 +18,7 @@ module Plurimath
|
|
|
22
18
|
parameter_two = nil,
|
|
23
19
|
options = {})
|
|
24
20
|
super(parameter_one, parameter_two)
|
|
25
|
-
@options = options unless options.
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def element_order=(value)
|
|
29
|
-
@temp_mathml_order = validated_order(
|
|
30
|
-
value&.map(&:name),
|
|
31
|
-
rejectable_array: ["comment"]
|
|
32
|
-
)
|
|
21
|
+
@options = options unless options.nil?
|
|
33
22
|
end
|
|
34
23
|
|
|
35
24
|
def to_mathml_without_math_tag(intent, options:)
|
|
@@ -46,6 +35,10 @@ module Plurimath
|
|
|
46
35
|
return base.to_omml_without_math_tag(display_style, options: options)
|
|
47
36
|
end
|
|
48
37
|
|
|
38
|
+
if @options[:accentunder]
|
|
39
|
+
return group_chr(display_style, options: options)
|
|
40
|
+
end
|
|
41
|
+
|
|
49
42
|
limlow = Utility.ox_element("limLow", namespace: "m")
|
|
50
43
|
limlowpr = Utility.ox_element("limLowPr", namespace: "m")
|
|
51
44
|
limlowpr << Utility.pr_element("ctrl", true, namespace: "m")
|
|
@@ -60,6 +53,23 @@ module Plurimath
|
|
|
60
53
|
[limlow]
|
|
61
54
|
end
|
|
62
55
|
|
|
56
|
+
def group_chr(display_style, options:)
|
|
57
|
+
groupchr = Utility.ox_element("groupChr", namespace: "m")
|
|
58
|
+
groupchrpr = Utility.ox_element("groupChrPR", namespace: "m")
|
|
59
|
+
chr = Utility.ox_element("chr", namespace: "m", attributes: { "m:val" => "_" })
|
|
60
|
+
pos = Utility.ox_element("pos", namespace: "m", attributes: { "m:val" => "bot" })
|
|
61
|
+
groupchrpr << chr
|
|
62
|
+
groupchrpr << pos
|
|
63
|
+
Utility.update_nodes(
|
|
64
|
+
groupchr,
|
|
65
|
+
[
|
|
66
|
+
groupchrpr,
|
|
67
|
+
omml_parameter(parameter_two, display_style, tag_name: "e", options: options),
|
|
68
|
+
],
|
|
69
|
+
)
|
|
70
|
+
[groupchr]
|
|
71
|
+
end
|
|
72
|
+
|
|
63
73
|
def to_unicodemath(options:)
|
|
64
74
|
return "#{parameter_one.to_unicodemath(options: options)}#{unicodemath_parens(parameter_two, options: options)}" if horizontal_brackets?
|
|
65
75
|
return "#{parameter_two.to_unicodemath(options: options)}_#{unicodemath_parens(parameter_one, options: options)}" if unicode_classes_accent?(parameter_two)
|
|
@@ -90,41 +100,8 @@ module Plurimath
|
|
|
90
100
|
parameter_two.is_nary_function? || parameter_two.is_nary_symbol?
|
|
91
101
|
end
|
|
92
102
|
|
|
93
|
-
def content=(value)
|
|
94
|
-
if no_content_in?(Array(value))
|
|
95
|
-
delete_all_text
|
|
96
|
-
else
|
|
97
|
-
new_val = Array(value).map do |val|
|
|
98
|
-
validate_symbols(val) unless val.strip.empty?
|
|
99
|
-
end
|
|
100
|
-
validate_text_order(new_val)
|
|
101
|
-
end
|
|
102
|
-
update_temp_mathml_values(@temp_mathml_order)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
103
|
protected
|
|
106
104
|
|
|
107
|
-
def validate_text_order(value)
|
|
108
|
-
@temp_mathml_order.each_with_index do |item, index|
|
|
109
|
-
next unless item == "text"
|
|
110
|
-
|
|
111
|
-
shifted_value = value.shift
|
|
112
|
-
next @temp_mathml_order[index] = shifted_value if shifted_value
|
|
113
|
-
|
|
114
|
-
@temp_mathml_order.delete_at(index)
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def delete_all_text
|
|
119
|
-
@temp_mathml_order.delete("text")
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def no_content_in?(value)
|
|
123
|
-
value.nil? ||
|
|
124
|
-
value.empty? ||
|
|
125
|
-
value&.all? { |val| val.strip.empty? }
|
|
126
|
-
end
|
|
127
|
-
|
|
128
105
|
def unicode_accent?(field)
|
|
129
106
|
return unless field.is_a?(Math::Symbols::Symbol)
|
|
130
107
|
|
|
@@ -76,7 +76,8 @@ module Plurimath
|
|
|
76
76
|
|
|
77
77
|
def wrapped_unitsml_xml(mathml, unitsml, options)
|
|
78
78
|
xml = Plurimath.xml_engine.load("<mrow>#{unitsml.to_xml(options.fetch(:unitsml, {}))}</mrow>")
|
|
79
|
-
|
|
79
|
+
xref = xml.nodes.find { |node| node.respond_to?(:[]) }&.[](:id)
|
|
80
|
+
mathml[:xref] = xref if xref
|
|
80
81
|
Utility.update_nodes(mathml, xml.nodes)
|
|
81
82
|
end
|
|
82
83
|
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "unary_function"
|
|
4
3
|
|
|
5
4
|
module Plurimath
|
|
6
5
|
module Math
|
|
@@ -86,6 +85,10 @@ module Plurimath
|
|
|
86
85
|
obj.update(Utility.filter_values(obj.value)) if obj.value_exist?
|
|
87
86
|
end
|
|
88
87
|
|
|
88
|
+
def accent_char
|
|
89
|
+
"→"
|
|
90
|
+
end
|
|
91
|
+
|
|
89
92
|
protected
|
|
90
93
|
|
|
91
94
|
def acc_tag(display_style, options:)
|
|
@@ -1,16 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Plurimath
|
|
2
4
|
module Math
|
|
3
5
|
module Function
|
|
6
|
+
autoload :Abs, "#{__dir__}/function/abs"
|
|
7
|
+
autoload :Arccos, "#{__dir__}/function/arccos"
|
|
8
|
+
autoload :Arcsin, "#{__dir__}/function/arcsin"
|
|
9
|
+
autoload :Arctan, "#{__dir__}/function/arctan"
|
|
10
|
+
autoload :Arg, "#{__dir__}/function/arg"
|
|
11
|
+
autoload :Bar, "#{__dir__}/function/bar"
|
|
12
|
+
autoload :Base, "#{__dir__}/function/base"
|
|
13
|
+
autoload :BinaryFunction, "#{__dir__}/function/binary_function"
|
|
14
|
+
autoload :Cancel, "#{__dir__}/function/cancel"
|
|
15
|
+
autoload :Ceil, "#{__dir__}/function/ceil"
|
|
16
|
+
autoload :Color, "#{__dir__}/function/color"
|
|
17
|
+
autoload :Cos, "#{__dir__}/function/cos"
|
|
18
|
+
autoload :Cosh, "#{__dir__}/function/cosh"
|
|
19
|
+
autoload :Cot, "#{__dir__}/function/cot"
|
|
20
|
+
autoload :Coth, "#{__dir__}/function/coth"
|
|
21
|
+
autoload :Csc, "#{__dir__}/function/csc"
|
|
22
|
+
autoload :Csch, "#{__dir__}/function/csch"
|
|
23
|
+
autoload :Ddot, "#{__dir__}/function/ddot"
|
|
24
|
+
autoload :Deg, "#{__dir__}/function/deg"
|
|
25
|
+
autoload :Det, "#{__dir__}/function/det"
|
|
26
|
+
autoload :Dim, "#{__dir__}/function/dim"
|
|
27
|
+
autoload :Dot, "#{__dir__}/function/dot"
|
|
28
|
+
autoload :Exp, "#{__dir__}/function/exp"
|
|
29
|
+
autoload :Fenced, "#{__dir__}/function/fenced"
|
|
30
|
+
autoload :Floor, "#{__dir__}/function/floor"
|
|
31
|
+
autoload :FontStyle, "#{__dir__}/function/font_style"
|
|
32
|
+
autoload :Frac, "#{__dir__}/function/frac"
|
|
33
|
+
autoload :Gcd, "#{__dir__}/function/gcd"
|
|
34
|
+
autoload :Glb, "#{__dir__}/function/glb"
|
|
35
|
+
autoload :Hat, "#{__dir__}/function/hat"
|
|
36
|
+
autoload :Hom, "#{__dir__}/function/hom"
|
|
37
|
+
autoload :Inf, "#{__dir__}/function/inf"
|
|
38
|
+
autoload :Int, "#{__dir__}/function/int"
|
|
39
|
+
autoload :Intent, "#{__dir__}/function/intent"
|
|
40
|
+
autoload :Ker, "#{__dir__}/function/ker"
|
|
41
|
+
autoload :Lcm, "#{__dir__}/function/lcm"
|
|
42
|
+
autoload :Left, "#{__dir__}/function/left"
|
|
43
|
+
autoload :Lg, "#{__dir__}/function/lg"
|
|
44
|
+
autoload :Lim, "#{__dir__}/function/lim"
|
|
45
|
+
autoload :Liminf, "#{__dir__}/function/liminf"
|
|
46
|
+
autoload :Limits, "#{__dir__}/function/limits"
|
|
47
|
+
autoload :Limsup, "#{__dir__}/function/limsup"
|
|
48
|
+
autoload :Linebreak, "#{__dir__}/function/linebreak"
|
|
49
|
+
autoload :Ln, "#{__dir__}/function/ln"
|
|
50
|
+
autoload :Log, "#{__dir__}/function/log"
|
|
51
|
+
autoload :Longdiv, "#{__dir__}/function/longdiv"
|
|
52
|
+
autoload :Lub, "#{__dir__}/function/lub"
|
|
53
|
+
autoload :Max, "#{__dir__}/function/max"
|
|
54
|
+
autoload :Mbox, "#{__dir__}/function/mbox"
|
|
55
|
+
autoload :Menclose, "#{__dir__}/function/menclose"
|
|
56
|
+
autoload :Merror, "#{__dir__}/function/merror"
|
|
57
|
+
autoload :Mglyph, "#{__dir__}/function/mglyph"
|
|
58
|
+
autoload :Min, "#{__dir__}/function/min"
|
|
59
|
+
autoload :Mlabeledtr, "#{__dir__}/function/mlabeledtr"
|
|
60
|
+
autoload :Mod, "#{__dir__}/function/mod"
|
|
61
|
+
autoload :Mpadded, "#{__dir__}/function/mpadded"
|
|
62
|
+
autoload :Ms, "#{__dir__}/function/ms"
|
|
63
|
+
autoload :Msgroup, "#{__dir__}/function/msgroup"
|
|
64
|
+
autoload :Msline, "#{__dir__}/function/msline"
|
|
65
|
+
autoload :Multiscript, "#{__dir__}/function/multiscript"
|
|
66
|
+
autoload :Nary, "#{__dir__}/function/nary"
|
|
67
|
+
autoload :None, "#{__dir__}/function/none"
|
|
68
|
+
autoload :Norm, "#{__dir__}/function/norm"
|
|
69
|
+
autoload :Obrace, "#{__dir__}/function/obrace"
|
|
70
|
+
autoload :Oint, "#{__dir__}/function/oint"
|
|
71
|
+
autoload :Over, "#{__dir__}/function/over"
|
|
72
|
+
autoload :Overbrace, "#{__dir__}/function/obrace"
|
|
73
|
+
autoload :Overline, "#{__dir__}/function/bar"
|
|
74
|
+
autoload :Overset, "#{__dir__}/function/overset"
|
|
75
|
+
autoload :Phantom, "#{__dir__}/function/phantom"
|
|
76
|
+
autoload :Power, "#{__dir__}/function/power"
|
|
77
|
+
autoload :PowerBase, "#{__dir__}/function/power_base"
|
|
78
|
+
autoload :Prod, "#{__dir__}/function/prod"
|
|
79
|
+
autoload :Right, "#{__dir__}/function/right"
|
|
80
|
+
autoload :Root, "#{__dir__}/function/root"
|
|
81
|
+
autoload :Rule, "#{__dir__}/function/rule"
|
|
82
|
+
autoload :Scarries, "#{__dir__}/function/scarries"
|
|
83
|
+
autoload :Scarry, "#{__dir__}/function/scarry"
|
|
84
|
+
autoload :Sec, "#{__dir__}/function/sec"
|
|
85
|
+
autoload :Sech, "#{__dir__}/function/sech"
|
|
86
|
+
autoload :Semantics, "#{__dir__}/function/semantics"
|
|
87
|
+
autoload :Sin, "#{__dir__}/function/sin"
|
|
88
|
+
autoload :Sinh, "#{__dir__}/function/sinh"
|
|
89
|
+
autoload :Sqrt, "#{__dir__}/function/sqrt"
|
|
90
|
+
autoload :Stackrel, "#{__dir__}/function/stackrel"
|
|
91
|
+
autoload :Substack, "#{__dir__}/function/substack"
|
|
92
|
+
autoload :Sum, "#{__dir__}/function/sum"
|
|
93
|
+
autoload :Sup, "#{__dir__}/function/sup"
|
|
94
|
+
autoload :Table, "#{__dir__}/function/table"
|
|
95
|
+
autoload :Tan, "#{__dir__}/function/tan"
|
|
96
|
+
autoload :Tanh, "#{__dir__}/function/tanh"
|
|
97
|
+
autoload :Td, "#{__dir__}/function/td"
|
|
98
|
+
autoload :TernaryFunction, "#{__dir__}/function/ternary_function"
|
|
99
|
+
autoload :Text, "#{__dir__}/function/text"
|
|
100
|
+
autoload :Tilde, "#{__dir__}/function/tilde"
|
|
101
|
+
autoload :Tr, "#{__dir__}/function/tr"
|
|
102
|
+
autoload :Ubrace, "#{__dir__}/function/ubrace"
|
|
103
|
+
autoload :Ul, "#{__dir__}/function/ul"
|
|
104
|
+
autoload :Underbrace, "#{__dir__}/function/ubrace"
|
|
105
|
+
autoload :Underline, "#{__dir__}/function/ul"
|
|
106
|
+
autoload :UnaryFunction, "#{__dir__}/function/unary_function"
|
|
107
|
+
autoload :Underover, "#{__dir__}/function/underover"
|
|
108
|
+
autoload :Underset, "#{__dir__}/function/underset"
|
|
109
|
+
autoload :Unitsml, "#{__dir__}/function/unitsml"
|
|
110
|
+
autoload :Vec, "#{__dir__}/function/vec"
|
|
4
111
|
end
|
|
5
112
|
end
|
|
6
113
|
end
|
|
7
|
-
|
|
8
|
-
# Include the first level files before the next
|
|
9
|
-
if RUBY_ENGINE != 'opal'
|
|
10
|
-
(
|
|
11
|
-
Dir.glob(File.join(__dir__, "function", "*.rb")) +
|
|
12
|
-
Dir.glob(File.join(__dir__, "function", "*", "*.rb"))
|
|
13
|
-
).each do |file|
|
|
14
|
-
require file
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../mathml/utility"
|
|
4
|
-
|
|
5
3
|
module Plurimath
|
|
6
4
|
module Math
|
|
7
5
|
class Number < Core
|
|
8
6
|
attr_accessor :value, :mini_sub_sized, :mini_sup_sized
|
|
9
|
-
include Mathml::Utility
|
|
10
7
|
|
|
11
8
|
def initialize(value = nil, mini_sub_sized: false, mini_sup_sized: false)
|
|
12
|
-
@value = value.is_a?(Parslet::Slice) ? value.to_s : value
|
|
9
|
+
@value = value.is_a?(::Parslet::Slice) ? value.to_s : value
|
|
13
10
|
@mini_sub_sized = mini_sub_sized if mini_sub_sized
|
|
14
11
|
@mini_sup_sized = mini_sup_sized if mini_sup_sized
|
|
15
12
|
end
|
|
@@ -95,9 +92,14 @@ module Plurimath
|
|
|
95
92
|
end
|
|
96
93
|
|
|
97
94
|
def format_value_with_options(options)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
formatter = options[:formatter]
|
|
96
|
+
if formatter&.respond_to?(:format)
|
|
97
|
+
formatter.format(options[:formula], self)
|
|
98
|
+
elsif formatter&.respond_to?(:localized_number)
|
|
99
|
+
formatter.localized_number(value.to_s)
|
|
100
|
+
else
|
|
101
|
+
value
|
|
102
|
+
end
|
|
101
103
|
end
|
|
102
104
|
end
|
|
103
105
|
end
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../../mathml/utility"
|
|
4
|
-
|
|
5
3
|
module Plurimath
|
|
6
4
|
module Math
|
|
7
5
|
module Symbols
|
|
8
6
|
class Symbol < Core
|
|
9
|
-
include Mathml::Utility
|
|
10
7
|
|
|
11
8
|
attr_accessor :value, :slashed, :mini_sub_sized, :mini_sup_sized, :options
|
|
12
9
|
|
|
@@ -27,7 +24,7 @@ module Plurimath
|
|
|
27
24
|
def ==(object)
|
|
28
25
|
object.respond_to?(:value) &&
|
|
29
26
|
object.class == self.class &&
|
|
30
|
-
object
|
|
27
|
+
comparable_value(object) == comparable_value(self) &&
|
|
31
28
|
object.slashed == slashed &&
|
|
32
29
|
object.mini_sub_sized == mini_sub_sized &&
|
|
33
30
|
object.mini_sup_sized == mini_sup_sized &&
|
|
@@ -167,6 +164,22 @@ module Plurimath
|
|
|
167
164
|
|
|
168
165
|
private
|
|
169
166
|
|
|
167
|
+
def comparable_value(symbol)
|
|
168
|
+
normalize_value(symbol.value || symbol.send(:default_value_for_comparison))
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def default_value_for_comparison
|
|
172
|
+
return if instance_of?(Symbol)
|
|
173
|
+
|
|
174
|
+
to_unicodemath
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def normalize_value(raw_value)
|
|
178
|
+
return if raw_value.nil?
|
|
179
|
+
|
|
180
|
+
Utility.html_entity_to_unicode(raw_value.to_s)
|
|
181
|
+
end
|
|
182
|
+
|
|
170
183
|
def t_element
|
|
171
184
|
Utility.ox_element("t", namespace: "m")
|
|
172
185
|
end
|