plurimath 0.3.3 → 0.3.4
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/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 +34 -23
- data/lib/plurimath/math/function/left.rb +1 -1
- data/lib/plurimath/math/function/right.rb +1 -1
- data/lib/plurimath/math/symbol.rb +1 -1
- data/lib/plurimath/mathml/constants.rb +2 -4
- 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: 1b189635567597c62c87de4beda13072f0be78d12993bbf8fb88d5a62447c0d9
|
4
|
+
data.tar.gz: 87960dc1944b7328585f44e8d8605dd5d94d00c2e29522ceebbf6e2f09936e18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4525b775b5ceb63822c1e4a0777604684b80b3c85403df64a8443d405a6e93bd3c8f354a905788558224f163caaf8a73eaca52f03f6042e409eae112f26d9805
|
7
|
+
data.tar.gz: b41b71415e9908bdd5bade1be722f48155473e556b050ecaebf097a21aaec1b478f63a2d72f60ead47b1a972f2c3b13623e6eb4837d426b489b39e7952bf4e0f
|
@@ -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
|
|
@@ -6,6 +6,11 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Fenced < TernaryFunction
|
9
|
+
def initialize(parameter_one = nil, parameter_two = nil, parameter_three = nil)
|
10
|
+
super
|
11
|
+
circular_parens
|
12
|
+
end
|
13
|
+
|
9
14
|
def to_asciimath
|
10
15
|
first_value = parameter_one ? parameter_one.to_asciimath : "("
|
11
16
|
third_value = parameter_three ? parameter_three.to_asciimath : ")"
|
@@ -33,8 +38,8 @@ module Plurimath
|
|
33
38
|
open_paren = parameter_one ? parameter_one.value : "("
|
34
39
|
fenced_value = parameter_two&.map(&:to_latex)&.join(" ")
|
35
40
|
close_paren = parameter_three ? parameter_three.value : ")"
|
36
|
-
first_value = latex_paren(open_paren
|
37
|
-
second_value = latex_paren(close_paren
|
41
|
+
first_value = latex_paren(open_paren)
|
42
|
+
second_value = latex_paren(close_paren)
|
38
43
|
"#{first_value} #{fenced_value} #{second_value}"
|
39
44
|
end
|
40
45
|
|
@@ -52,25 +57,6 @@ module Plurimath
|
|
52
57
|
|
53
58
|
protected
|
54
59
|
|
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
60
|
def first_value(dpr)
|
75
61
|
first_value = parameter_one&.value
|
76
62
|
return dpr if first_value.nil? || first_value.empty?
|
@@ -83,6 +69,18 @@ module Plurimath
|
|
83
69
|
)
|
84
70
|
end
|
85
71
|
|
72
|
+
def second_value
|
73
|
+
class_names = ["number", "symbol"].freeze
|
74
|
+
parameter_two&.map do |object|
|
75
|
+
e_tag = Utility.ox_element("e", namespace: "m")
|
76
|
+
e_tag << if class_names.include?(object.class_name)
|
77
|
+
fenced_omml_value(object)
|
78
|
+
else
|
79
|
+
object&.to_omml_without_math_tag
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
86
84
|
def third_value(dpr)
|
87
85
|
third_value = parameter_three&.value
|
88
86
|
return dpr if third_value.nil? || third_value.empty?
|
@@ -95,11 +93,19 @@ module Plurimath
|
|
95
93
|
)
|
96
94
|
end
|
97
95
|
|
98
|
-
def
|
96
|
+
def fenced_omml_value(object)
|
97
|
+
r_tag = Utility.ox_element("r", namespace: "m")
|
98
|
+
t_tag = Utility.ox_element("t", namespace: "m")
|
99
|
+
t_tag << object&.value
|
100
|
+
r_tag << t_tag
|
101
|
+
end
|
102
|
+
|
103
|
+
def latex_paren(paren)
|
99
104
|
return "" if paren.nil? || paren.empty?
|
100
105
|
|
101
106
|
paren = %w[{ }].include?(paren) ? "\\#{paren}" : paren
|
102
|
-
"
|
107
|
+
paren = "\\#{Latex::Constants::UNICODE_SYMBOLS.invert[paren]}" if paren.to_s.match?(/\&#x.{0,4};/)
|
108
|
+
paren.to_s
|
103
109
|
end
|
104
110
|
|
105
111
|
def mathml_paren(field)
|
@@ -107,6 +113,11 @@ module Plurimath
|
|
107
113
|
|
108
114
|
field&.value
|
109
115
|
end
|
116
|
+
|
117
|
+
def circular_parens
|
118
|
+
parameter_one&.value = "〈" if Utility.symbol_value(parameter_one, "ᑕ")
|
119
|
+
parameter_three&.value = "〉" if Utility.symbol_value(parameter_three, "ᑐ")
|
120
|
+
end
|
110
121
|
end
|
111
122
|
end
|
112
123
|
end
|
@@ -93,8 +93,8 @@ module Plurimath
|
|
93
93
|
"⊨": "|==",
|
94
94
|
"〈": "(:",
|
95
95
|
"〉": ":)",
|
96
|
-
"&#
|
97
|
-
"&#
|
96
|
+
"〈": "<<",
|
97
|
+
"〉": ">>",
|
98
98
|
"∫": "int",
|
99
99
|
"∮": "oint",
|
100
100
|
"∂": "del",
|
@@ -225,8 +225,6 @@ module Plurimath
|
|
225
225
|
log
|
226
226
|
ul
|
227
227
|
ln
|
228
|
-
f
|
229
|
-
g
|
230
228
|
].freeze
|
231
229
|
OPERATORS = [
|
232
230
|
"    ",
|
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.4
|
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-15 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
|