plurimath 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AsciiMath-Supported-Data.adoc +2 -4
- data/MathML-Supported-Data.adoc +2 -4
- data/lib/plurimath/asciimath/constants.rb +2 -4
- data/lib/plurimath/asciimath/parse.rb +9 -10
- data/lib/plurimath/asciimath/parser.rb +2 -0
- data/lib/plurimath/asciimath/transform.rb +1 -1
- data/lib/plurimath/html/constants.rb +0 -2
- data/lib/plurimath/html/transform.rb +34 -0
- data/lib/plurimath/latex/constants.rb +5 -5
- data/lib/plurimath/latex/parse.rb +7 -7
- data/lib/plurimath/math/function/fenced.rb +24 -23
- data/lib/plurimath/math/function/left.rb +1 -1
- data/lib/plurimath/math/function/right.rb +1 -1
- data/lib/plurimath/math/function/table.rb +6 -2
- data/lib/plurimath/math/symbol.rb +1 -1
- data/lib/plurimath/mathml/constants.rb +2 -6
- data/lib/plurimath/utility.rb +2 -0
- data/lib/plurimath/version.rb +1 -1
- metadata +2 -4
- data/lib/plurimath/math/function/f.rb +0 -20
- data/lib/plurimath/math/function/g.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18df410d2655f777a8bf6379ec49334cc4d595e73b100e61287e5c385674a7b3
|
4
|
+
data.tar.gz: ae5bcfd6527302f5811b80ab02d61c4f25027c9526720402467736d2d4ccdf10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 671778813a9f27fc1911226f587c93ee156591abf54acba8f922dc620caa8fd13019c72ce40695a659ba8455745ddd007a19d6fc1444cafd1744946d97ae7f1d
|
7
|
+
data.tar.gz: 522d01abb0c1d7482fd3d1ff598891007540559f8031d9ad0f53379d9eac577c89e666f827225325df4a10c8ea504479fbb523c11e171cbd7cbc2b96000afaa1
|
@@ -86,8 +86,6 @@
|
|
86
86
|
* `sec`
|
87
87
|
* `ln`
|
88
88
|
* `ul`
|
89
|
-
* `g`
|
90
|
-
* `f`
|
91
89
|
|
92
90
|
|
93
91
|
== Symbols
|
@@ -1588,10 +1586,10 @@
|
|
1588
1586
|
| `Lbrack` | ⟦
|
1589
1587
|
| `rBrack` | ⟧
|
1590
1588
|
| `Rbrack` | ⟧
|
1591
|
-
| `langle` | &#
|
1589
|
+
| `langle` | 〈
|
1592
1590
|
| `lAngle` | ⟪
|
1593
1591
|
| `rAngle` | ⟫
|
1594
|
-
| `rangle` | &#
|
1592
|
+
| `rangle` | 〉
|
1595
1593
|
| `lgroup` | ⟮
|
1596
1594
|
| `rgroup` | ⟯
|
1597
1595
|
| `Mapsto` | ⤇
|
data/MathML-Supported-Data.adoc
CHANGED
@@ -72,8 +72,6 @@
|
|
72
72
|
* `sec`
|
73
73
|
* `ln`
|
74
74
|
* `ul`
|
75
|
-
* `g`
|
76
|
-
* `f`
|
77
75
|
|
78
76
|
|
79
77
|
=== Tags
|
@@ -214,8 +212,8 @@
|
|
214
212
|
| `\⊨` | ⊨
|
215
213
|
| `\〈` | 〈
|
216
214
|
| `\〉` | 〉
|
217
|
-
| `\&#
|
218
|
-
| `\&#
|
215
|
+
| `\〈` | 〈
|
216
|
+
| `\〉` | 〉
|
219
217
|
| `\∫` | ∫
|
220
218
|
| `\∮` | ∮
|
221
219
|
| `\∂` | ∂
|
@@ -4,13 +4,13 @@ module Plurimath
|
|
4
4
|
class Asciimath
|
5
5
|
class Constants
|
6
6
|
TABLE_PARENTHESIS = {
|
7
|
-
"
|
7
|
+
"ᑕ": "ᑐ",
|
8
8
|
"ℒ": "ℛ",
|
9
9
|
"[": "]",
|
10
10
|
"(": ")",
|
11
11
|
}.freeze
|
12
12
|
PARENTHESIS = {
|
13
|
-
"
|
13
|
+
"ᑕ": "ᑐ",
|
14
14
|
"ℒ": "ℛ",
|
15
15
|
"(": ")",
|
16
16
|
"{": "}",
|
@@ -286,8 +286,6 @@ module Plurimath
|
|
286
286
|
vec
|
287
287
|
ul
|
288
288
|
ln
|
289
|
-
f
|
290
|
-
g
|
291
289
|
].freeze
|
292
290
|
BINARY_CLASSES = %i[
|
293
291
|
underset
|
@@ -58,8 +58,8 @@ module Plurimath
|
|
58
58
|
end
|
59
59
|
|
60
60
|
rule(:quoted_text) do
|
61
|
-
str('"') >> match("[^\"]").repeat.as(:text) >> str('"') |
|
62
|
-
str('"') >> str("").as(:text)
|
61
|
+
(str('"') >> match("[^\"]").repeat.as(:text) >> str('"')) |
|
62
|
+
(str('"') >> str("").as(:text))
|
63
63
|
end
|
64
64
|
|
65
65
|
rule(:symbol_text_or_integer) do
|
@@ -70,7 +70,7 @@ module Plurimath
|
|
70
70
|
quoted_text |
|
71
71
|
(str("d").as(:d) >> str("x").as(:x)).as(:intermediate_exp) |
|
72
72
|
match["a-zA-Z"].as(:symbol) |
|
73
|
-
match(/[^\[{(\\\/@;:.,'"|\]})0-9a-zA-Z\-><$%^&*_=+!`~\s
|
73
|
+
match(/[^\[{(\\\/@;:.,'"|\]})0-9a-zA-Z\-><$%^&*_=+!`~\s?ℒℛᑕᑐ]/).as(:symbol) |
|
74
74
|
number
|
75
75
|
end
|
76
76
|
|
@@ -89,16 +89,15 @@ module Plurimath
|
|
89
89
|
end
|
90
90
|
|
91
91
|
rule(:table) do
|
92
|
-
(
|
93
|
-
(open_table.as(:table_left) >> tr >>
|
94
|
-
(str("norm").as(:norm) >> open_table.as(:table_left) >> tr >> close_table.as(:table_right)) |
|
95
|
-
(str("
|
96
|
-
(str("
|
97
|
-
(str("left") >> left_right_open_paren.as(:left) >> tr >> str("right") >> left_right_close_paren.as(:right))
|
92
|
+
(str("{").as(:table_left) >> space.maybe >> tr >> space.maybe >> close_table.as(:table_right)) |
|
93
|
+
(open_table.as(:table_left) >> space.maybe >> tr >> space.maybe >> close_table.as(:table_right)) |
|
94
|
+
(str("norm").as(:norm) >> open_table.as(:table_left) >> space.maybe >> tr >> space.maybe >> close_table.as(:table_right)) |
|
95
|
+
(str("|").as(:table_left) >> space.maybe >> tr >> space.maybe >> str("|").as(:table_right)) |
|
96
|
+
(str("left") >> left_right_open_paren.as(:left) >> space.maybe >> tr >> space.maybe >> str("right") >> left_right_close_paren.as(:right))
|
98
97
|
end
|
99
98
|
|
100
99
|
rule(:tr) do
|
101
|
-
((left_right_open_paren.as(:open_tr) >> td.as(:tds_list) >> left_right_close_paren).as(:table_row) >> comma >> tr.as(:expr)) |
|
100
|
+
((left_right_open_paren.as(:open_tr) >> td.as(:tds_list) >> left_right_close_paren).as(:table_row) >> comma >> space.maybe >> tr.as(:expr)) |
|
102
101
|
(left_right_open_paren.as(:open_tr) >> td.as(:tds_list) >> left_right_close_paren).as(:table_row)
|
103
102
|
end
|
104
103
|
|
@@ -407,7 +407,7 @@ module Plurimath
|
|
407
407
|
rule(power_base: simple(:power_base),
|
408
408
|
base: simple(:base)) do
|
409
409
|
if base.is_a?(Math::Formula) && base.value.any? { |value| Utility.symbol_value(value, ",") }
|
410
|
-
sliced = base.value.slice_before { |object| Utility.symbol_value(object, ",")
|
410
|
+
sliced = base.value.slice_before { |object| Utility.symbol_value(object, ",") }.to_a
|
411
411
|
base_object = Math::Function::Base.new(
|
412
412
|
power_base,
|
413
413
|
Utility.filter_values(
|
@@ -36,6 +36,11 @@ module Plurimath
|
|
36
36
|
[sequence, expr]
|
37
37
|
end
|
38
38
|
|
39
|
+
rule(sequence: simple(:sequence),
|
40
|
+
parse_parenthesis: simple(:parse_paren)) do
|
41
|
+
[sequence, parse_paren]
|
42
|
+
end
|
43
|
+
|
39
44
|
rule(sequence: simple(:sequence),
|
40
45
|
expression: sequence(:expr)) do
|
41
46
|
expr.insert(0, sequence)
|
@@ -72,6 +77,13 @@ module Plurimath
|
|
72
77
|
)
|
73
78
|
end
|
74
79
|
|
80
|
+
rule(unary_function: simple(:unary_function),
|
81
|
+
sequence: sequence(:sequence)) do
|
82
|
+
Math::Formula.new(
|
83
|
+
([unary_function] + sequence),
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
75
87
|
rule(text: simple(:text),
|
76
88
|
expression: simple(:expr)) do
|
77
89
|
[
|
@@ -250,6 +262,16 @@ module Plurimath
|
|
250
262
|
end
|
251
263
|
end
|
252
264
|
|
265
|
+
rule(sub_sup: simple(:sub_sup),
|
266
|
+
sup_value: sequence(:sup_value),
|
267
|
+
expression: simple(:expression)) do
|
268
|
+
power = Math::Function::Power.new(
|
269
|
+
sub_sup,
|
270
|
+
Math::Formula.new(sup_value),
|
271
|
+
)
|
272
|
+
[power, expression]
|
273
|
+
end
|
274
|
+
|
253
275
|
rule(lparen: simple(:lparen),
|
254
276
|
text: simple(:text),
|
255
277
|
rparen: simple(:rparen)) do
|
@@ -270,6 +292,18 @@ module Plurimath
|
|
270
292
|
])
|
271
293
|
end
|
272
294
|
|
295
|
+
rule(lparen: simple(:lparen),
|
296
|
+
sequence: simple(:sequence),
|
297
|
+
parse_parenthesis: simple(:parse_paren),
|
298
|
+
rparen: simple(:rparen)) do
|
299
|
+
Math::Formula.new([
|
300
|
+
Math::Symbol.new(lparen),
|
301
|
+
sequence,
|
302
|
+
parse_paren,
|
303
|
+
Math::Symbol.new(rparen),
|
304
|
+
])
|
305
|
+
end
|
306
|
+
|
273
307
|
rule(lparen: simple(:lparen),
|
274
308
|
sequence: sequence(:sequence),
|
275
309
|
rparen: simple(:rparen)) do
|
@@ -1311,8 +1311,8 @@ module Plurimath
|
|
1311
1311
|
Lbrack: "⟦",
|
1312
1312
|
rBrack: "⟧",
|
1313
1313
|
Rbrack: "⟧",
|
1314
|
-
langle: "&#
|
1315
|
-
rangle: "&#
|
1314
|
+
langle: "〈",
|
1315
|
+
rangle: "〉",
|
1316
1316
|
lAngle: "⟪",
|
1317
1317
|
rAngle: "⟫",
|
1318
1318
|
lgroup: "⟮",
|
@@ -3787,8 +3787,8 @@ module Plurimath
|
|
3787
3787
|
].freeze
|
3788
3788
|
LEFT_RIGHT_PARENTHESIS = {
|
3789
3789
|
"\\backslash": "\",
|
3790
|
-
"\\langle": "&#
|
3791
|
-
"\\rangle": "&#
|
3790
|
+
"\\langle": "〈",
|
3791
|
+
"\\rangle": "〉",
|
3792
3792
|
"\\lfloor": "⌊",
|
3793
3793
|
"\\rfloor": "⌋",
|
3794
3794
|
"\\lceil": "⌈",
|
@@ -3828,7 +3828,7 @@ module Plurimath
|
|
3828
3828
|
|
|
3829
3829
|
}
|
3830
3830
|
{
|
3831
|
-
]
|
3831
|
+
].freeze
|
3832
3832
|
end
|
3833
3833
|
end
|
3834
3834
|
end
|
@@ -90,7 +90,7 @@ module Plurimath
|
|
90
90
|
(slash >> math_operators_classes) |
|
91
91
|
match["a-zA-Z"].as(:symbols) |
|
92
92
|
match(/\d+(\.[0-9]+)|\d/).repeat(1).as(:number) |
|
93
|
-
str("\\\\").as("\\\\") >> match(/\s/).repeat |
|
93
|
+
(str("\\\\").as("\\\\") >> match(/\s/).repeat) |
|
94
94
|
str("\\ ").as(:space)
|
95
95
|
end
|
96
96
|
|
@@ -140,10 +140,10 @@ module Plurimath
|
|
140
140
|
(expression.repeat.as(:dividend) >> str("\\over") >> expression.repeat.as(:divisor)) |
|
141
141
|
expression.as(:expression).maybe
|
142
142
|
) >>
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
(
|
144
|
+
str("\\right").as(:right).maybe >> (right_parens | str(".").maybe)
|
145
|
+
)
|
146
|
+
)
|
147
147
|
end
|
148
148
|
|
149
149
|
rule(:over_class) do
|
@@ -156,7 +156,7 @@ module Plurimath
|
|
156
156
|
|
157
157
|
rule(:iteration) do
|
158
158
|
(sequence.as(:sequence) >> iteration.as(:expression)) |
|
159
|
-
sequence >> expression.maybe
|
159
|
+
(sequence >> expression.maybe)
|
160
160
|
end
|
161
161
|
|
162
162
|
rule(:expression) do
|
@@ -204,7 +204,7 @@ module Plurimath
|
|
204
204
|
when :binary
|
205
205
|
(slashed_value(first_value, :binary) >> intermediate_exp.as(:first_value) >> intermediate_exp.as(:second_value)).as(:binary)
|
206
206
|
when :text
|
207
|
-
(slashed_value(first_value, :text) >> (str("{") >>
|
207
|
+
(slashed_value(first_value, :text) >> (str("{") >> match("[^}]").repeat.as(:first_value) >> str("}")))
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
@@ -33,8 +33,8 @@ module Plurimath
|
|
33
33
|
open_paren = parameter_one ? parameter_one.value : "("
|
34
34
|
fenced_value = parameter_two&.map(&:to_latex)&.join(" ")
|
35
35
|
close_paren = parameter_three ? parameter_three.value : ")"
|
36
|
-
first_value = latex_paren(open_paren
|
37
|
-
second_value = latex_paren(close_paren
|
36
|
+
first_value = latex_paren(open_paren)
|
37
|
+
second_value = latex_paren(close_paren)
|
38
38
|
"#{first_value} #{fenced_value} #{second_value}"
|
39
39
|
end
|
40
40
|
|
@@ -52,25 +52,6 @@ module Plurimath
|
|
52
52
|
|
53
53
|
protected
|
54
54
|
|
55
|
-
def second_value
|
56
|
-
class_names = ["number", "symbol"].freeze
|
57
|
-
parameter_two&.map do |object|
|
58
|
-
e_tag = Utility.ox_element("e", namespace: "m")
|
59
|
-
e_tag << if class_names.include?(object.class_name)
|
60
|
-
fenced_omml_value(object)
|
61
|
-
else
|
62
|
-
object&.to_omml_without_math_tag
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def fenced_omml_value(object)
|
68
|
-
r_tag = Utility.ox_element("r", namespace: "m")
|
69
|
-
t_tag = Utility.ox_element("t", namespace: "m")
|
70
|
-
t_tag << object&.value
|
71
|
-
r_tag << t_tag
|
72
|
-
end
|
73
|
-
|
74
55
|
def first_value(dpr)
|
75
56
|
first_value = parameter_one&.value
|
76
57
|
return dpr if first_value.nil? || first_value.empty?
|
@@ -83,6 +64,18 @@ module Plurimath
|
|
83
64
|
)
|
84
65
|
end
|
85
66
|
|
67
|
+
def second_value
|
68
|
+
class_names = ["number", "symbol"].freeze
|
69
|
+
parameter_two&.map do |object|
|
70
|
+
e_tag = Utility.ox_element("e", namespace: "m")
|
71
|
+
e_tag << if class_names.include?(object.class_name)
|
72
|
+
fenced_omml_value(object)
|
73
|
+
else
|
74
|
+
object&.to_omml_without_math_tag
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
86
79
|
def third_value(dpr)
|
87
80
|
third_value = parameter_three&.value
|
88
81
|
return dpr if third_value.nil? || third_value.empty?
|
@@ -95,11 +88,19 @@ module Plurimath
|
|
95
88
|
)
|
96
89
|
end
|
97
90
|
|
98
|
-
def
|
91
|
+
def fenced_omml_value(object)
|
92
|
+
r_tag = Utility.ox_element("r", namespace: "m")
|
93
|
+
t_tag = Utility.ox_element("t", namespace: "m")
|
94
|
+
t_tag << object&.value
|
95
|
+
r_tag << t_tag
|
96
|
+
end
|
97
|
+
|
98
|
+
def latex_paren(paren)
|
99
99
|
return "" if paren.nil? || paren.empty?
|
100
100
|
|
101
101
|
paren = %w[{ }].include?(paren) ? "\\#{paren}" : paren
|
102
|
-
"
|
102
|
+
paren = "\\#{Latex::Constants::UNICODE_SYMBOLS.invert[paren]}" if paren.to_s.match?(/\&#x.{0,4};/)
|
103
|
+
paren.to_s
|
103
104
|
end
|
104
105
|
|
105
106
|
def mathml_paren(field)
|
@@ -129,6 +129,7 @@ module Plurimath
|
|
129
129
|
def mathml_attrs(column_strings)
|
130
130
|
args = options&.dup&.reject { |arg| arg.to_s == "asterisk" }
|
131
131
|
args[:columnlines] = column_strings.join(" ") if column_strings.include?("solid")
|
132
|
+
args[:columnalign] = "left" if close_paren&.include?(":}")
|
132
133
|
args
|
133
134
|
end
|
134
135
|
|
@@ -152,8 +153,11 @@ module Plurimath
|
|
152
153
|
def latex_columnalign
|
153
154
|
return "" unless Hash(options)[:asterisk]
|
154
155
|
|
155
|
-
|
156
|
-
|
156
|
+
"[#{Utility::ALIGNMENT_LETTERS.invert[Hash(td_hash)[:columnalign]]}]"
|
157
|
+
end
|
158
|
+
|
159
|
+
def td_hash
|
160
|
+
value&.first&.parameter_one&.first&.parameter_two
|
157
161
|
end
|
158
162
|
|
159
163
|
def environment
|
@@ -91,10 +91,8 @@ module Plurimath
|
|
91
91
|
"⊤": "TT",
|
92
92
|
"⊢": "|--",
|
93
93
|
"⊨": "|==",
|
94
|
-
"〈": "
|
95
|
-
"〉": "
|
96
|
-
"⟨": "<<",
|
97
|
-
"⟩": ">>",
|
94
|
+
"〈": "<<",
|
95
|
+
"〉": ">>",
|
98
96
|
"∫": "int",
|
99
97
|
"∮": "oint",
|
100
98
|
"∂": "del",
|
@@ -225,8 +223,6 @@ module Plurimath
|
|
225
223
|
log
|
226
224
|
ul
|
227
225
|
ln
|
228
|
-
f
|
229
|
-
g
|
230
226
|
].freeze
|
231
227
|
OPERATORS = [
|
232
228
|
"    ",
|
data/lib/plurimath/utility.rb
CHANGED
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.5
|
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-06-
|
11
|
+
date: 2023-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|
@@ -101,7 +101,6 @@ files:
|
|
101
101
|
- lib/plurimath/math/function/dim.rb
|
102
102
|
- lib/plurimath/math/function/dot.rb
|
103
103
|
- lib/plurimath/math/function/exp.rb
|
104
|
-
- lib/plurimath/math/function/f.rb
|
105
104
|
- lib/plurimath/math/function/fenced.rb
|
106
105
|
- lib/plurimath/math/function/floor.rb
|
107
106
|
- lib/plurimath/math/function/font_style.rb
|
@@ -114,7 +113,6 @@ files:
|
|
114
113
|
- lib/plurimath/math/function/font_style/sans-serif.rb
|
115
114
|
- lib/plurimath/math/function/font_style/script.rb
|
116
115
|
- lib/plurimath/math/function/frac.rb
|
117
|
-
- lib/plurimath/math/function/g.rb
|
118
116
|
- lib/plurimath/math/function/gcd.rb
|
119
117
|
- lib/plurimath/math/function/glb.rb
|
120
118
|
- lib/plurimath/math/function/hat.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "unary_function"
|
4
|
-
|
5
|
-
module Plurimath
|
6
|
-
module Math
|
7
|
-
module Function
|
8
|
-
class F < UnaryFunction
|
9
|
-
def to_asciimath
|
10
|
-
"f#{parameter_one&.to_asciimath}"
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_latex
|
14
|
-
first_value = latex_value if parameter_one
|
15
|
-
"f#{first_value}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "unary_function"
|
4
|
-
|
5
|
-
module Plurimath
|
6
|
-
module Math
|
7
|
-
module Function
|
8
|
-
class G < UnaryFunction
|
9
|
-
def to_asciimath
|
10
|
-
"g#{parameter_one&.to_asciimath}"
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_latex
|
14
|
-
"g#{parameter_one&.to_latex}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|