plurimath 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/plurimath/latex/constants.rb +1 -0
- data/lib/plurimath/latex/parse.rb +9 -3
- data/lib/plurimath/latex/transform.rb +16 -0
- data/lib/plurimath/math/formula.rb +1 -0
- data/lib/plurimath/math/function/fenced.rb +1 -0
- data/lib/plurimath/math/function/sqrt.rb +4 -2
- data/lib/plurimath/mathml/constants.rb +1 -0
- data/lib/plurimath/omml/transform.rb +19 -5
- data/lib/plurimath/utility.rb +2 -2
- data/lib/plurimath/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4c3f2e8fb24ec72671101a001b6a359f1bf678a19b229f7238c7e250bb2689b
|
4
|
+
data.tar.gz: 1899fb80d23b9145c6a9b61d4fec13d521b3abadf57f81201101ad32b166b816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57dd9fc70c73e8e29209dce21f08dcc4ab16473cf155cf29f19560bfabb0680ca22c4e337b0d766057c6357e24aae1f55a1965f79c881ead796d69730b153337
|
7
|
+
data.tar.gz: c16720307e808c0e7efe6435302b622aab66ec7dcc2a4df95a898d6b637a834464fd500e33362398033ed1422b3059db63e8577e267a68fbfb09007738af0623
|
@@ -15,7 +15,12 @@ module Plurimath
|
|
15
15
|
end
|
16
16
|
|
17
17
|
rule(:begining) do
|
18
|
-
(slash >> str("begin") >> (str("{") >> symbol_text_or_integer >> str("*").as(:asterisk)
|
18
|
+
(slash >> str("begin") >> (str("{") >> symbol_text_or_integer >> str("*").as(:asterisk) >> str("}")) >> optional_args.maybe) |
|
19
|
+
(slash >> str("begin") >> (str("{") >> symbol_text_or_integer >> str("}")))
|
20
|
+
end
|
21
|
+
|
22
|
+
rule(:array_begin) do
|
23
|
+
(str("\\begin{") >> str("array").as(:environment) >> str("}"))
|
19
24
|
end
|
20
25
|
|
21
26
|
rule(:ending) do
|
@@ -91,7 +96,8 @@ module Plurimath
|
|
91
96
|
match["a-zA-Z"].as(:symbols) |
|
92
97
|
match(/\d+(\.[0-9]+)|\d/).repeat(1).as(:number) |
|
93
98
|
(str("\\\\").as("\\\\") >> match(/\s/).repeat) |
|
94
|
-
str("\\ ").as(:space)
|
99
|
+
str("\\ ").as(:space) |
|
100
|
+
(str("\\operatorname{") >> match("[^}]").repeat.as(:symbols) >> str("}"))
|
95
101
|
end
|
96
102
|
|
97
103
|
rule(:intermediate_exp) do
|
@@ -133,7 +139,7 @@ module Plurimath
|
|
133
139
|
(left_right.as(:left_right) >> base >> intermediate_exp.as(:subscript)) |
|
134
140
|
left_right.as(:left_right) |
|
135
141
|
(slash >> str("substack").as(:substack) >> intermediate_exp) |
|
136
|
-
(
|
142
|
+
(array_begin >> array_args >> expression.as(:table_data) >> ending).as(:environment) |
|
137
143
|
(begining >> expression.as(:table_data) >> ending).as(:environment) |
|
138
144
|
(slash >> environment >> intermediate_exp).as(:table_data) |
|
139
145
|
power_base |
|
@@ -275,6 +275,14 @@ module Plurimath
|
|
275
275
|
)
|
276
276
|
end
|
277
277
|
|
278
|
+
rule(operant: simple(:operant),
|
279
|
+
supscript: simple(:supscript)) do
|
280
|
+
Math::Function::Power.new(
|
281
|
+
Math::Symbol.new(operant),
|
282
|
+
supscript,
|
283
|
+
)
|
284
|
+
end
|
285
|
+
|
278
286
|
rule(sequence: simple(:sequence),
|
279
287
|
expression: simple(:expr)) do
|
280
288
|
[sequence, expr].compact
|
@@ -446,6 +454,14 @@ module Plurimath
|
|
446
454
|
)
|
447
455
|
end
|
448
456
|
|
457
|
+
rule(intermediate_exp: simple(:int_exp),
|
458
|
+
subscript: simple(:subscript)) do
|
459
|
+
Math::Function::Base.new(
|
460
|
+
int_exp,
|
461
|
+
subscript,
|
462
|
+
)
|
463
|
+
end
|
464
|
+
|
449
465
|
rule(unicode_symbols: simple(:sym),
|
450
466
|
subscript: simple(:subscript)) do
|
451
467
|
Math::Function::Base.new(
|
@@ -139,6 +139,7 @@ module Plurimath
|
|
139
139
|
def nary_tag_able?(display_style)
|
140
140
|
value.length == 2 &&
|
141
141
|
["underover", "powerbase"].include?(value&.first&.class_name) &&
|
142
|
+
!value.first.parameter_one.is_a?(Function::FontStyle) &&
|
142
143
|
(
|
143
144
|
value&.first&.parameter_one&.to_omml_without_math_tag(display_style)&.length == 1 ||
|
144
145
|
value&.first&.parameter_one.to_omml_without_math_tag(display_style).match?(/^&#x\w*\d*;$/)
|
@@ -84,6 +84,7 @@ module Plurimath
|
|
84
84
|
|
85
85
|
def latex_paren(paren)
|
86
86
|
return "" if paren.nil? || paren.empty?
|
87
|
+
return paren.gsub(":", "") if paren.include?(":") && ["{:", ":}"].include?(paren)
|
87
88
|
|
88
89
|
paren = %w[{ }].include?(paren) ? "\\#{paren}" : paren
|
89
90
|
paren = "\\#{Latex::Constants::UNICODE_SYMBOLS.invert[paren]}" if paren&.to_s&.match?(/&#x.{0,4};/)
|
@@ -8,8 +8,10 @@ module Plurimath
|
|
8
8
|
class Sqrt < UnaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
10
|
sqrt_tag = Utility.ox_element("msqrt")
|
11
|
-
|
12
|
-
|
11
|
+
Utility.update_nodes(
|
12
|
+
sqrt_tag,
|
13
|
+
Array(parameter_one&.to_mathml_without_math_tag),
|
14
|
+
)
|
13
15
|
sqrt_tag
|
14
16
|
end
|
15
17
|
|
@@ -12,7 +12,6 @@ module Plurimath
|
|
12
12
|
rule(val: simple(:val)) { val }
|
13
13
|
rule(scr: simple(:scr)) { scr }
|
14
14
|
rule(sty: simple(:sty)) { sty }
|
15
|
-
rule(dPr: subtree(:dpr)) { dpr }
|
16
15
|
rule(num: subtree(:num)) { num }
|
17
16
|
rule(den: subtree(:den)) { den }
|
18
17
|
rule(fPr: subtree(:fPr)) { nil }
|
@@ -22,7 +21,6 @@ module Plurimath
|
|
22
21
|
rule(deg: sequence(:deg)) { Utility.filter_values(deg) }
|
23
22
|
rule(sub: sequence(:sub)) { Utility.filter_values(sub) }
|
24
23
|
rule(sup: sequence(:sup)) { Utility.filter_values(sup) }
|
25
|
-
rule(mtd: sequence(:mtd)) { mtd.flatten.compact }
|
26
24
|
rule(boxPr: subtree(:box)) { nil }
|
27
25
|
rule(argPr: subtree(:arg)) { nil }
|
28
26
|
rule(accPr: subtree(:acc)) { acc.flatten.compact }
|
@@ -107,12 +105,28 @@ module Plurimath
|
|
107
105
|
)
|
108
106
|
end
|
109
107
|
|
108
|
+
rule(dPr: subtree(:dpr)) do
|
109
|
+
dpr.reject! { |d| d.is_a?(Hash) }
|
110
|
+
dpr
|
111
|
+
end
|
112
|
+
|
113
|
+
rule(mtd: sequence(:mtd)) do
|
114
|
+
flatten_mtd = mtd&.flatten&.compact
|
115
|
+
if flatten_mtd.length > 1 && !flatten_mtd.first.is_a?(Math::Core)
|
116
|
+
font = flatten_mtd.shift
|
117
|
+
font.new(
|
118
|
+
Utility.filter_values(flatten_mtd),
|
119
|
+
Utility::OMML_FONTS.invert[font].to_s,
|
120
|
+
)
|
121
|
+
else
|
122
|
+
flatten_mtd
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
110
126
|
rule(mr: subtree(:mr)) do
|
111
127
|
row = []
|
112
128
|
mr.each do |td|
|
113
|
-
row << Math::Function::Td.new(
|
114
|
-
Array(td),
|
115
|
-
)
|
129
|
+
row << Math::Function::Td.new(Array(td))
|
116
130
|
end
|
117
131
|
Math::Function::Tr.new(row)
|
118
132
|
end
|
data/lib/plurimath/utility.rb
CHANGED
@@ -562,8 +562,8 @@ module Plurimath
|
|
562
562
|
close_paren = mrow.pop
|
563
563
|
if mrow.length == 1 && mrow.first.is_a?(Math::Function::Table)
|
564
564
|
table = mrow.first
|
565
|
-
table.open_paren = open_paren
|
566
|
-
table.close_paren = close_paren
|
565
|
+
table.open_paren = open_paren.value
|
566
|
+
table.close_paren = close_paren.value
|
567
567
|
else
|
568
568
|
mrow.replace(
|
569
569
|
[
|
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.4.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2023-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|