plurimath 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +8 -11
- data/.gitignore +1 -0
- data/AsciiMath-Supported-Data.adoc +280 -0
- data/Gemfile +1 -0
- data/Latex-Supported-Data.adoc +1872 -0
- data/MathML-Supported-Data.adoc +270 -0
- data/README.adoc +94 -0
- data/lib/plurimath/asciimath/constants.rb +215 -222
- data/lib/plurimath/asciimath/parse.rb +45 -11
- data/lib/plurimath/asciimath/parser.rb +4 -3
- data/lib/plurimath/asciimath/transform.rb +222 -131
- data/lib/plurimath/asciimath.rb +1 -1
- data/lib/plurimath/html/constants.rb +50 -0
- data/lib/plurimath/html/parse.rb +149 -0
- data/lib/plurimath/html/parser.rb +26 -0
- data/lib/plurimath/html/transform.rb +363 -0
- data/lib/plurimath/html.rb +1 -1
- data/lib/plurimath/latex/constants.rb +1885 -1858
- data/lib/plurimath/latex/parse.rb +127 -34
- data/lib/plurimath/latex/parser.rb +5 -4
- data/lib/plurimath/latex/transform.rb +324 -164
- data/lib/plurimath/math/formula.rb +9 -1
- data/lib/plurimath/math/function/bar.rb +1 -1
- data/lib/plurimath/math/function/base.rb +7 -1
- data/lib/plurimath/math/function/binary_function.rb +10 -5
- data/lib/plurimath/math/function/color.rb +4 -4
- data/lib/plurimath/math/function/fenced.rb +7 -2
- data/lib/plurimath/math/function/font_style/bold.rb +18 -0
- data/lib/plurimath/math/function/font_style/double_struck.rb +18 -0
- data/lib/plurimath/math/function/font_style/fraktur.rb +18 -0
- data/lib/plurimath/math/function/font_style/monospace.rb +18 -0
- data/lib/plurimath/math/function/font_style/sans-serif.rb +18 -0
- data/lib/plurimath/math/function/font_style/script.rb +18 -0
- data/lib/plurimath/math/function/font_style.rb +2 -22
- data/lib/plurimath/math/function/frac.rb +4 -4
- data/lib/plurimath/math/function/inf.rb +0 -1
- data/lib/plurimath/math/function/left.rb +3 -6
- data/lib/plurimath/math/function/limits.rb +0 -1
- data/lib/plurimath/math/function/log.rb +6 -0
- data/lib/plurimath/math/function/mod.rb +6 -0
- data/lib/plurimath/math/function/multiscript.rb +11 -0
- data/lib/plurimath/math/function/norm.rb +2 -1
- data/lib/plurimath/math/function/over.rb +29 -0
- data/lib/plurimath/math/function/overset.rb +2 -2
- data/lib/plurimath/math/function/power.rb +7 -1
- data/lib/plurimath/math/function/power_base.rb +14 -7
- data/lib/plurimath/math/function/prod.rb +6 -0
- data/lib/plurimath/math/function/right.rb +24 -0
- data/lib/plurimath/math/function/root.rb +5 -4
- data/lib/plurimath/math/function/sqrt.rb +1 -1
- data/lib/plurimath/math/function/substack.rb +0 -1
- data/lib/plurimath/math/function/sum.rb +6 -0
- data/lib/plurimath/math/function/table/align.rb +24 -0
- data/lib/plurimath/math/function/table/array.rb +25 -0
- data/lib/plurimath/math/function/table/bmatrix.rb +26 -0
- data/lib/plurimath/math/function/table/matrix.rb +24 -0
- data/lib/plurimath/math/function/table/multline.rb +24 -0
- data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
- data/lib/plurimath/math/function/table/split.rb +24 -0
- data/lib/plurimath/math/function/table/vmatrix.rb +25 -0
- data/lib/plurimath/math/function/table.rb +17 -5
- data/lib/plurimath/math/function/td.rb +6 -1
- data/lib/plurimath/math/function/ternary_function.rb +16 -6
- data/lib/plurimath/math/function/text.rb +19 -7
- data/lib/plurimath/math/function/tr.rb +6 -1
- data/lib/plurimath/math/function/unary_function.rb +5 -0
- data/lib/plurimath/math/function/vec.rb +4 -0
- data/lib/plurimath/math/function.rb +13 -2
- data/lib/plurimath/math/number.rb +8 -0
- data/lib/plurimath/math/symbol.rb +12 -3
- data/lib/plurimath/math.rb +9 -4
- data/lib/plurimath/mathml/constants.rb +2 -34
- data/lib/plurimath/mathml/parse.rb +7 -2
- data/lib/plurimath/mathml/parser.rb +2 -1
- data/lib/plurimath/mathml/transform.rb +73 -68
- data/lib/plurimath/mathml.rb +1 -1
- data/lib/plurimath/omml/constants.rb +154 -0
- data/lib/plurimath/omml/parser.rb +22 -0
- data/lib/plurimath/omml/transform.rb +216 -0
- data/lib/plurimath/omml.rb +1 -1
- data/lib/plurimath/unitsml.rb +4 -0
- data/lib/plurimath/utility.rb +73 -0
- data/lib/plurimath/version.rb +1 -1
- data/plurimath.gemspec +1 -0
- metadata +49 -7
- data/README.md +0 -40
@@ -0,0 +1,270 @@
|
|
1
|
+
=== MathML Support
|
2
|
+
|
3
|
+
==== Classes
|
4
|
+
|===
|
5
|
+
| Functions | Fonts
|
6
|
+
|
7
|
+
| stackrel | double-struck
|
8
|
+
| underset | sans-serif
|
9
|
+
| mathfrak | monospace
|
10
|
+
| mathcal | fraktur
|
11
|
+
| overset | script
|
12
|
+
| cancel | bold
|
13
|
+
| obrace |
|
14
|
+
| ubrace |
|
15
|
+
| mathtt |
|
16
|
+
| mathbf |
|
17
|
+
| mathbb |
|
18
|
+
| mathsf |
|
19
|
+
| arctan |
|
20
|
+
| arcsin |
|
21
|
+
| arccos |
|
22
|
+
| color |
|
23
|
+
| floor |
|
24
|
+
| tilde |
|
25
|
+
| prod |
|
26
|
+
| text |
|
27
|
+
| norm |
|
28
|
+
| sqrt |
|
29
|
+
| cosh |
|
30
|
+
| tanh |
|
31
|
+
| sinh |
|
32
|
+
| sech |
|
33
|
+
| csch |
|
34
|
+
| coth |
|
35
|
+
| ddot |
|
36
|
+
| ceil |
|
37
|
+
| oint |
|
38
|
+
| root |
|
39
|
+
| frac |
|
40
|
+
| log |
|
41
|
+
| mod |
|
42
|
+
| vec |
|
43
|
+
| hat |
|
44
|
+
| dot |
|
45
|
+
| bar |
|
46
|
+
| abs |
|
47
|
+
| min |
|
48
|
+
| max |
|
49
|
+
| dim |
|
50
|
+
| det |
|
51
|
+
| csc |
|
52
|
+
| cot |
|
53
|
+
| lub |
|
54
|
+
| lcm |
|
55
|
+
| glb |
|
56
|
+
| gcd |
|
57
|
+
| exp |
|
58
|
+
| sum |
|
59
|
+
| cos |
|
60
|
+
| tan |
|
61
|
+
| sin |
|
62
|
+
| int |
|
63
|
+
| sec |
|
64
|
+
| ln |
|
65
|
+
| ul |
|
66
|
+
| g |
|
67
|
+
| f |
|
68
|
+
|===
|
69
|
+
|
70
|
+
==== Tags
|
71
|
+
** annotation_xml
|
72
|
+
** annotation-xml
|
73
|
+
** mmultiscripts
|
74
|
+
** maligngroup
|
75
|
+
** munderover
|
76
|
+
** annotation
|
77
|
+
** malignmark
|
78
|
+
** semantics
|
79
|
+
** mscarries
|
80
|
+
** menclose
|
81
|
+
** mlongdiv
|
82
|
+
** mphantom
|
83
|
+
** mfenced
|
84
|
+
** msgroup
|
85
|
+
** maction
|
86
|
+
** mpadded
|
87
|
+
** msubsup
|
88
|
+
** mscarry
|
89
|
+
** msline
|
90
|
+
** mspace
|
91
|
+
** mstack
|
92
|
+
** mstyle
|
93
|
+
** mtable
|
94
|
+
** munder
|
95
|
+
** merror
|
96
|
+
** msqrt
|
97
|
+
** mroot
|
98
|
+
** msrow
|
99
|
+
** mover
|
100
|
+
** mfrac
|
101
|
+
** math
|
102
|
+
** mrow
|
103
|
+
** msub
|
104
|
+
** msup
|
105
|
+
** mtd
|
106
|
+
** mtr
|
107
|
+
** mn
|
108
|
+
** mo
|
109
|
+
** mi
|
110
|
+
** ms
|
111
|
+
|
112
|
+
==== Unicodes
|
113
|
+
** \α
|
114
|
+
** \β
|
115
|
+
** \γ
|
116
|
+
** \Γ
|
117
|
+
** \δ
|
118
|
+
** \Δ
|
119
|
+
** \∆
|
120
|
+
** \ε
|
121
|
+
** \ɛ
|
122
|
+
** \ζ
|
123
|
+
** \η
|
124
|
+
** \θ
|
125
|
+
** \Θ
|
126
|
+
** \ϑ
|
127
|
+
** \ι
|
128
|
+
** \κ
|
129
|
+
** \λ
|
130
|
+
** \Λ
|
131
|
+
** \μ
|
132
|
+
** \ν
|
133
|
+
** \ξ
|
134
|
+
** \Ξ
|
135
|
+
** \π
|
136
|
+
** \Π
|
137
|
+
** \ρ
|
138
|
+
** \ς
|
139
|
+
** \σ
|
140
|
+
** \Σ
|
141
|
+
** \τ
|
142
|
+
** \υ
|
143
|
+
** \φ
|
144
|
+
** \Φ
|
145
|
+
** \ϕ
|
146
|
+
** \χ
|
147
|
+
** \ψ
|
148
|
+
** \Ψ
|
149
|
+
** \ω
|
150
|
+
** \Ω
|
151
|
+
** \⋅
|
152
|
+
** \∙
|
153
|
+
** \·
|
154
|
+
** \∗
|
155
|
+
** \⋆
|
156
|
+
** \×
|
157
|
+
** \⋉
|
158
|
+
** \⋊
|
159
|
+
** \⋈
|
160
|
+
** \÷
|
161
|
+
** \∘
|
162
|
+
** \⊕
|
163
|
+
** \⨁
|
164
|
+
** \⊗
|
165
|
+
** \⊙
|
166
|
+
** \∑
|
167
|
+
** \∏
|
168
|
+
** \∏
|
169
|
+
** \∧
|
170
|
+
** \⋀
|
171
|
+
** \∨
|
172
|
+
** \⋁
|
173
|
+
** \∩
|
174
|
+
** \⋂
|
175
|
+
** \∪
|
176
|
+
** \⋃
|
177
|
+
** \≠
|
178
|
+
** \≤
|
179
|
+
** \≥
|
180
|
+
** \≺
|
181
|
+
** \≻
|
182
|
+
** \⪯
|
183
|
+
** \⪰
|
184
|
+
** \∈
|
185
|
+
** \∉
|
186
|
+
** \⊂
|
187
|
+
** \⊃
|
188
|
+
** \⊆
|
189
|
+
** \⊇
|
190
|
+
** \≡
|
191
|
+
** \≅
|
192
|
+
** \≈
|
193
|
+
** \∝
|
194
|
+
** \¬
|
195
|
+
** \∀
|
196
|
+
** \∃
|
197
|
+
** \⊥
|
198
|
+
** \⊤
|
199
|
+
** \⊢
|
200
|
+
** \⊨
|
201
|
+
** \〈
|
202
|
+
** \〉
|
203
|
+
** \⟨
|
204
|
+
** \⟩
|
205
|
+
** \∫
|
206
|
+
** \∮
|
207
|
+
** \∂
|
208
|
+
** \∇
|
209
|
+
** \±
|
210
|
+
** \∅
|
211
|
+
** \∞
|
212
|
+
** \ℵ
|
213
|
+
** \∴
|
214
|
+
** \∵
|
215
|
+
** \∠
|
216
|
+
** \△
|
217
|
+
** \′
|
218
|
+
** \  
|
219
|
+
** \    
|
220
|
+
** \⌢
|
221
|
+
** \⋯
|
222
|
+
** \⋮
|
223
|
+
** \⋱
|
224
|
+
** \⋄
|
225
|
+
** \□
|
226
|
+
** \⌊
|
227
|
+
** \⌋
|
228
|
+
** \⌈
|
229
|
+
** \⌉
|
230
|
+
** \ℂ
|
231
|
+
** \ℕ
|
232
|
+
** \ℚ
|
233
|
+
** \ℝ
|
234
|
+
** \ℤ
|
235
|
+
** \↑
|
236
|
+
** \↓
|
237
|
+
** \←
|
238
|
+
** \↔
|
239
|
+
** \⇒
|
240
|
+
** \⇐
|
241
|
+
** \⇔
|
242
|
+
** \→
|
243
|
+
** \↣
|
244
|
+
** \↠
|
245
|
+
** \⤖
|
246
|
+
** \↦
|
247
|
+
** \…
|
248
|
+
** \−
|
249
|
+
** \⁡
|
250
|
+
** \⏞
|
251
|
+
** \⏟
|
252
|
+
|
253
|
+
=== Symbols
|
254
|
+
** |
|
255
|
+
** /
|
256
|
+
** \
|
257
|
+
** ~
|
258
|
+
** (
|
259
|
+
** )
|
260
|
+
** (:
|
261
|
+
** :)
|
262
|
+
** {
|
263
|
+
** }
|
264
|
+
** {:
|
265
|
+
** :}
|
266
|
+
** ]
|
267
|
+
** [
|
268
|
+
** =
|
269
|
+
** +
|
270
|
+
** -
|
data/README.adoc
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
= Plurimath
|
2
|
+
|
3
|
+
This gem implements a mechanism of conversion between Math languages mentioned below.
|
4
|
+
|
5
|
+
1. **AsciiMath**
|
6
|
+
2. **MathML**
|
7
|
+
3. **Latex**
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem "plurimath"
|
15
|
+
```
|
16
|
+
And then execute:
|
17
|
+
```shell
|
18
|
+
|
19
|
+
$ bundle install
|
20
|
+
```
|
21
|
+
Or install it yourself as:
|
22
|
+
```shell
|
23
|
+
$ gem install plurimath
|
24
|
+
```
|
25
|
+
|
26
|
+
== Usage
|
27
|
+
|
28
|
+
Pass the string you want to convert and Math type of the string provided, which will give you **Plurimath::Math::Formula** object as output, Let's see some examples below.
|
29
|
+
|
30
|
+
=== Conversion Examples
|
31
|
+
|
32
|
+
==== Asciimath Formula Example
|
33
|
+
[source, ruby]
|
34
|
+
----
|
35
|
+
asciimath = "sin(1)"
|
36
|
+
formula = Plurimath::Math.parse(asciimath, :asciimath)
|
37
|
+
----
|
38
|
+
==== MathML Formula Example
|
39
|
+
[source, ruby]
|
40
|
+
----
|
41
|
+
mathml = <<~MATHML
|
42
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
43
|
+
<mstyle displaystyle='true'>
|
44
|
+
<mi>sin</mi>
|
45
|
+
<mn>1</mn>
|
46
|
+
</mstyle>
|
47
|
+
</math>
|
48
|
+
MATHML
|
49
|
+
formula = Plurimath::Math.parse(mathml, "mathml")
|
50
|
+
----
|
51
|
+
==== Latex Formula Example
|
52
|
+
[source, ruby]
|
53
|
+
----
|
54
|
+
latex = "\\sin{1}"
|
55
|
+
formula = Plurimath::Math.parse(latex, "latex")
|
56
|
+
----
|
57
|
+
---
|
58
|
+
Since we have the object of **Plurimath::Formula**,We can generate **AsciiMath**, **MathMl** or **Latex** string from the formula object,All we have to do is call conversion function on formula object, see examples below.
|
59
|
+
|
60
|
+
==== AsciiMath Output conversion
|
61
|
+
[source, ruby]
|
62
|
+
----
|
63
|
+
formula.to_asciimath
|
64
|
+
> sin(1)
|
65
|
+
----
|
66
|
+
==== Latex Output conversion
|
67
|
+
[source, ruby]
|
68
|
+
----
|
69
|
+
formula.to_latex
|
70
|
+
> \\sin1
|
71
|
+
----
|
72
|
+
==== MathML Output conversion
|
73
|
+
[source, ruby]
|
74
|
+
----
|
75
|
+
formula.to_mathml
|
76
|
+
> <math xmlns='http://www.w3.org/1998/Math/MathML'>
|
77
|
+
> <mstyle displaystyle='true'>
|
78
|
+
> <mi>sin</mi>
|
79
|
+
> <mn>1</mn>
|
80
|
+
> </mstyle>
|
81
|
+
> </math>
|
82
|
+
----
|
83
|
+
=== Supported Content
|
84
|
+
--
|
85
|
+
include::AsciiMath-Supported-Data.adoc[]
|
86
|
+
--
|
87
|
+
|
88
|
+
--
|
89
|
+
include::MathML-Supported-Data.adoc[]
|
90
|
+
--
|
91
|
+
|
92
|
+
--
|
93
|
+
include::Latex-Supported-Data.adoc[]
|
94
|
+
--
|