mathml2latex 0.1.1
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 +7 -0
- data/README.md +47 -0
- data/Rakefile +19 -0
- data/lib/mathml2latex.rb +27 -0
- data/lib/mathml2latex/mathml_latex_service.rb +42 -0
- data/lib/mathml2latex/symbols.rb +1561 -0
- data/lib/mathml2latex/version.rb +3 -0
- data/lib/mathml2latex/xslt/elements/menclose.xsl +39 -0
- data/lib/mathml2latex/xslt/elements/merror.xsl +8 -0
- data/lib/mathml2latex/xslt/elements/mfenced.xsl +64 -0
- data/lib/mathml2latex/xslt/elements/mfrac.xsl +56 -0
- data/lib/mathml2latex/xslt/elements/mi_mn_mo_mtext_ms.xsl +199 -0
- data/lib/mathml2latex/xslt/elements/mmultiscripts.xsl +61 -0
- data/lib/mathml2latex/xslt/elements/mover.xsl +66 -0
- data/lib/mathml2latex/xslt/elements/mphantom.xsl +10 -0
- data/lib/mathml2latex/xslt/elements/mroot.xsl +21 -0
- data/lib/mathml2latex/xslt/elements/mrow.xsl +8 -0
- data/lib/mathml2latex/xslt/elements/mspace.xsl +24 -0
- data/lib/mathml2latex/xslt/elements/msqrt.xsl +10 -0
- data/lib/mathml2latex/xslt/elements/mstyle.xsl +39 -0
- data/lib/mathml2latex/xslt/elements/msub.xsl +12 -0
- data/lib/mathml2latex/xslt/elements/msubsup.xsl +14 -0
- data/lib/mathml2latex/xslt/elements/msup.xsl +12 -0
- data/lib/mathml2latex/xslt/elements/mtable.xsl +86 -0
- data/lib/mathml2latex/xslt/elements/mtd.xsl +30 -0
- data/lib/mathml2latex/xslt/elements/mtr.xsl +11 -0
- data/lib/mathml2latex/xslt/elements/munder.xsl +73 -0
- data/lib/mathml2latex/xslt/elements/munderover.xsl +92 -0
- data/lib/mathml2latex/xslt/includes.xsl +30 -0
- data/lib/mathml2latex/xslt/mml2latex.xsl +30 -0
- data/lib/mathml2latex/xslt/shared/color.xsl +117 -0
- data/lib/mathml2latex/xslt_functions.rb +29 -0
- data/spec/fixtures/basic/aligned_equations.xml +37 -0
- data/spec/fixtures/basic/arrow_accent.xml +11 -0
- data/spec/fixtures/basic/backspace.xml +6 -0
- data/spec/fixtures/basic/bottom_parenthesis.xml +12 -0
- data/spec/fixtures/basic/definite_integral_with_differential.xml +17 -0
- data/spec/fixtures/basic/digit_space.xml +6 -0
- data/spec/fixtures/basic/double_vertical_bars.xml +10 -0
- data/spec/fixtures/basic/element_over.xml +15 -0
- data/spec/fixtures/basic/element_under.xml +17 -0
- data/spec/fixtures/basic/element_under_over.xml +23 -0
- data/spec/fixtures/basic/enclose_box_matrix.xml +28 -0
- data/spec/fixtures/basic/enclose_left.xml +9 -0
- data/spec/fixtures/basic/enclose_right.xml +8 -0
- data/spec/fixtures/basic/fraction.xml +6 -0
- data/spec/fixtures/basic/greek.xml +30 -0
- data/spec/fixtures/basic/left_right_arrow_accent.xml +12 -0
- data/spec/fixtures/basic/left_subscript.xml +15 -0
- data/spec/fixtures/basic/left_super_sub_script.xml +21 -0
- data/spec/fixtures/basic/left_superscript.xml +15 -0
- data/spec/fixtures/basic/matrix.xml +26 -0
- data/spec/fixtures/basic/matrix_bottom_curly_bracket.xml +32 -0
- data/spec/fixtures/basic/matrix_curly_brackets.xml +30 -0
- data/spec/fixtures/basic/matrix_parenthesis.xml +28 -0
- data/spec/fixtures/basic/matrix_square_brackets.xml +30 -0
- data/spec/fixtures/basic/matrix_top_curly_bracket.xml +32 -0
- data/spec/fixtures/basic/matrix_with_vertical_bar.xml +30 -0
- data/spec/fixtures/basic/n_root.xml +6 -0
- data/spec/fixtures/basic/over_script_with_brace.xml +18 -0
- data/spec/fixtures/basic/parenthesis.xml +9 -0
- data/spec/fixtures/basic/piecewise_function.xml +22 -0
- data/spec/fixtures/basic/square_root.xml +5 -0
- data/spec/fixtures/basic/subscript.xml +13 -0
- data/spec/fixtures/basic/subscript_with_big_operator.xml +10 -0
- data/spec/fixtures/basic/sum_over_under.xml +13 -0
- data/spec/fixtures/basic/sum_super_sub.xml +9 -0
- data/spec/fixtures/basic/super_sub_script.xml +18 -0
- data/spec/fixtures/basic/super_sub_script_big_operator.xml +18 -0
- data/spec/fixtures/basic/superscript.xml +9 -0
- data/spec/fixtures/basic/top_parenthesis.xml +6 -0
- data/spec/fixtures/basic/under_script_with_brace.xml +18 -0
- data/spec/fixtures/basic/vector_accent.xml +13 -0
- data/spec/fixtures/complex/sum_with_nested_matrix.xml +79 -0
- data/spec/lib/mathml2latex/mathml_latex_service_spec.rb +383 -0
- data/spec/lib/mathml2latex/xslt_functions_spec.rb +39 -0
- data/spec/mathml2latex_spec.rb +52 -0
- data/spec/spec_helper.rb +15 -0
- metadata +257 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
|
2
|
+
<mi>b</mi>
|
|
3
|
+
<mi>a</mi>
|
|
4
|
+
<mi>s</mi>
|
|
5
|
+
<msubsup>
|
|
6
|
+
<mi>e</mi>
|
|
7
|
+
<mrow>
|
|
8
|
+
<mi>s</mi>
|
|
9
|
+
<mi>u</mi>
|
|
10
|
+
<mi>b</mi>
|
|
11
|
+
</mrow>
|
|
12
|
+
<mrow>
|
|
13
|
+
<mi>s</mi>
|
|
14
|
+
<mi>u</mi>
|
|
15
|
+
<mi>p</mi>
|
|
16
|
+
</mrow>
|
|
17
|
+
</msubsup>
|
|
18
|
+
</math>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
|
2
|
+
<msubsup>
|
|
3
|
+
<mo largeop="true">base</mo>
|
|
4
|
+
<mrow>
|
|
5
|
+
<mi>u</mi>
|
|
6
|
+
<mi>n</mi>
|
|
7
|
+
<mi>d</mi>
|
|
8
|
+
<mi>e</mi>
|
|
9
|
+
<mi>r</mi>
|
|
10
|
+
</mrow>
|
|
11
|
+
<mrow>
|
|
12
|
+
<mi>o</mi>
|
|
13
|
+
<mi>v</mi>
|
|
14
|
+
<mi>e</mi>
|
|
15
|
+
<mi>r</mi>
|
|
16
|
+
</mrow>
|
|
17
|
+
</msubsup>
|
|
18
|
+
</math>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
|
2
|
+
<munder>
|
|
3
|
+
<munder>
|
|
4
|
+
<mrow>
|
|
5
|
+
<mi>u</mi>
|
|
6
|
+
<mi>p</mi>
|
|
7
|
+
</mrow>
|
|
8
|
+
<mo>⏟</mo>
|
|
9
|
+
</munder>
|
|
10
|
+
<mrow>
|
|
11
|
+
<mi>u</mi>
|
|
12
|
+
<mi>n</mi>
|
|
13
|
+
<mi>d</mi>
|
|
14
|
+
<mi>e</mi>
|
|
15
|
+
<mi>r</mi>
|
|
16
|
+
</mrow>
|
|
17
|
+
</munder>
|
|
18
|
+
</math>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
|
3
|
+
<mstyle displaystyle="false">
|
|
4
|
+
<munder>
|
|
5
|
+
<mo>∑</mo>
|
|
6
|
+
<mfenced open="|" close="|">
|
|
7
|
+
<mtable>
|
|
8
|
+
<mtr>
|
|
9
|
+
<mtd>
|
|
10
|
+
<mn>1</mn>
|
|
11
|
+
</mtd>
|
|
12
|
+
<mtd>
|
|
13
|
+
<mn>2</mn>
|
|
14
|
+
</mtd>
|
|
15
|
+
<mtd>
|
|
16
|
+
<mn>3</mn>
|
|
17
|
+
</mtd>
|
|
18
|
+
</mtr>
|
|
19
|
+
<mtr>
|
|
20
|
+
<mtd>
|
|
21
|
+
<mn>4</mn>
|
|
22
|
+
</mtd>
|
|
23
|
+
<mtd>
|
|
24
|
+
<mfenced open="{" close="">
|
|
25
|
+
<mtable columnalign="left">
|
|
26
|
+
<mtr>
|
|
27
|
+
<mtd>
|
|
28
|
+
<mn>11</mn>
|
|
29
|
+
</mtd>
|
|
30
|
+
</mtr>
|
|
31
|
+
<mtr>
|
|
32
|
+
<mtd>
|
|
33
|
+
<mfenced open="[" close="]">
|
|
34
|
+
<mtable>
|
|
35
|
+
<mtr>
|
|
36
|
+
<mtd>
|
|
37
|
+
<mn>1</mn>
|
|
38
|
+
</mtd>
|
|
39
|
+
<mtd>
|
|
40
|
+
<mn>2</mn>
|
|
41
|
+
</mtd>
|
|
42
|
+
<mtd>
|
|
43
|
+
<mn>3</mn>
|
|
44
|
+
</mtd>
|
|
45
|
+
</mtr>
|
|
46
|
+
<mtr>
|
|
47
|
+
<mtd>
|
|
48
|
+
<mn>4</mn>
|
|
49
|
+
</mtd>
|
|
50
|
+
<mtd>
|
|
51
|
+
<mn>5</mn>
|
|
52
|
+
</mtd>
|
|
53
|
+
<mtd>
|
|
54
|
+
<msubsup>
|
|
55
|
+
<mo>∫</mo>
|
|
56
|
+
<mi>a</mi>
|
|
57
|
+
<mi>b</mi>
|
|
58
|
+
</msubsup>
|
|
59
|
+
<mi>x</mi>
|
|
60
|
+
<mo>d</mo>
|
|
61
|
+
<mi>x</mi>
|
|
62
|
+
</mtd>
|
|
63
|
+
</mtr>
|
|
64
|
+
</mtable>
|
|
65
|
+
</mfenced>
|
|
66
|
+
</mtd>
|
|
67
|
+
</mtr>
|
|
68
|
+
</mtable>
|
|
69
|
+
</mfenced>
|
|
70
|
+
</mtd>
|
|
71
|
+
<mtd>
|
|
72
|
+
<mn>6</mn>
|
|
73
|
+
</mtd>
|
|
74
|
+
</mtr>
|
|
75
|
+
</mtable>
|
|
76
|
+
</mfenced>
|
|
77
|
+
</munder>
|
|
78
|
+
</mstyle>
|
|
79
|
+
</math>
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Mathml2latex::MathmlLatexService do
|
|
4
|
+
let(:fixtures_path) { File.join('spec', 'fixtures') }
|
|
5
|
+
let(:service) { Mathml2latex::MathmlLatexService.get_service_object }
|
|
6
|
+
subject { service.to_latex_from_file(mathml_path) }
|
|
7
|
+
|
|
8
|
+
describe 'basic to_latex' do
|
|
9
|
+
context 'basic fraction' do
|
|
10
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'fraction.xml') }
|
|
11
|
+
|
|
12
|
+
it 'outputs correct latex' do
|
|
13
|
+
expect(subject).to eq('\frac{1}{2}')
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'basic square root' do
|
|
18
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'square_root.xml') }
|
|
19
|
+
|
|
20
|
+
it 'outputs correct latex' do
|
|
21
|
+
expect(subject).to eq('\sqrt{\mathrm{ss}}')
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context 'basic n root' do
|
|
26
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'n_root.xml') }
|
|
27
|
+
|
|
28
|
+
it 'outputs correct latex' do
|
|
29
|
+
expect(subject).to eq('\sqrt[a]{b}')
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'basic superscript' do
|
|
34
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'superscript.xml') }
|
|
35
|
+
|
|
36
|
+
it 'outputs correct latex' do
|
|
37
|
+
expect(subject).to eq('{a}^{bx}')
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context 'basic left superscript' do
|
|
42
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'left_superscript.xml') }
|
|
43
|
+
|
|
44
|
+
it 'outputs correct latex' do
|
|
45
|
+
expect(subject).to eq('{}^{sup}base')
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context 'basic superscript and subscript' do
|
|
50
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'super_sub_script.xml') }
|
|
51
|
+
|
|
52
|
+
it 'outputs correct latex' do
|
|
53
|
+
expect(subject).to eq('bas{e}_{sub}^{sup}')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context 'basic left superscript and subscript' do
|
|
58
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'left_super_sub_script.xml') }
|
|
59
|
+
|
|
60
|
+
it 'outputs correct latex' do
|
|
61
|
+
expect(subject).to eq('{}_{sub}{}^{super}base')
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
context 'basic subscript' do
|
|
66
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'subscript.xml') }
|
|
67
|
+
|
|
68
|
+
it 'outputs correct latex' do
|
|
69
|
+
expect(subject).to eq('bas{e}_{sub}')
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context 'basic left subscript' do
|
|
74
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'left_subscript.xml') }
|
|
75
|
+
|
|
76
|
+
it 'outputs correct latex' do
|
|
77
|
+
expect(subject).to eq('{}_{sub}base')
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context 'basic element over' do
|
|
82
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'element_over.xml') }
|
|
83
|
+
|
|
84
|
+
it 'outputs correct latex' do
|
|
85
|
+
expect(subject).to eq('\overset{top}{base}')
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
context 'basic element under and over' do
|
|
90
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'element_under_over.xml') }
|
|
91
|
+
|
|
92
|
+
it 'outputs correct latex' do
|
|
93
|
+
expect(subject).to eq('\underset{under}{\overset{over}{base}}')
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context 'basic element under' do
|
|
98
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'element_under.xml') }
|
|
99
|
+
|
|
100
|
+
it 'outputs correct latex' do
|
|
101
|
+
expect(subject).to eq('\underset{under}{base}')
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
context 'basic under script with brace' do
|
|
106
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'under_script_with_brace.xml') }
|
|
107
|
+
|
|
108
|
+
it 'outputs correct latex' do
|
|
109
|
+
expect(subject).to eq('\underset{under}{\underbrace{up}}')
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
context 'basic over script with brace' do
|
|
114
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'over_script_with_brace.xml') }
|
|
115
|
+
|
|
116
|
+
it 'outputs correct latex' do
|
|
117
|
+
expect(subject).to eq('\overset{top}{\overbrace{base}}')
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
context 'basic superscript and subscript with big operator' do
|
|
122
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'super_sub_script_big_operator.xml') }
|
|
123
|
+
|
|
124
|
+
it 'outputs correct latex' do
|
|
125
|
+
expect(subject).to eq('{\mbox{\large$base$}}_{under}^{over}')
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
context 'basic subscript with big operator' do
|
|
130
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'subscript_with_big_operator.xml') }
|
|
131
|
+
|
|
132
|
+
it 'outputs correct latex' do
|
|
133
|
+
expect(subject).to eq('{\mbox{\large$base$}}_{sub}')
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
context 'basic backspace' do
|
|
138
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'backspace.xml') }
|
|
139
|
+
|
|
140
|
+
it 'outputs correct latex' do
|
|
141
|
+
expect(subject).to eq('223444\phantom{\rule{-0.2em}{0ex}}333\phantom{\rule{-0.2em}{0ex}}')
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
context 'basic digit space' do
|
|
146
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'digit_space.xml') }
|
|
147
|
+
|
|
148
|
+
it 'outputs correct latex' do
|
|
149
|
+
expect(subject).to eq('123\, 456\phantom{\rule{-0.2em}{0ex}}')
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
context 'basic greek characters' do
|
|
154
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'greek.xml') }
|
|
155
|
+
|
|
156
|
+
it 'outputs correct latex' do
|
|
157
|
+
expect(subject).to match(
|
|
158
|
+
/\\alpha \\beta \\gamma \\delta \\varepsilon \\zeta \\eta/
|
|
159
|
+
)
|
|
160
|
+
expect(subject).to match(
|
|
161
|
+
/\\theta \\vartheta \\iota \\kappa \\lambda \\mu \\nu \\xi o \\pi/
|
|
162
|
+
)
|
|
163
|
+
expect(subject).to match(
|
|
164
|
+
/\\varpi \\rho \\varsigma \\sigma \\tau \\upsilon \\varphi \\phi \\chi \\psi \\omega/
|
|
165
|
+
)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
context 'basic matrix' do
|
|
170
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'matrix.xml') }
|
|
171
|
+
|
|
172
|
+
it 'outputs correct latex' do
|
|
173
|
+
# actual result: \begin{array}{ccc}11& 12& 13\\ 21& 22& 23\end{array}
|
|
174
|
+
expect(subject).to eq('\begin{array}{ccc}11& 12& 13\\\\ 21& 22& 23\end{array}')
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
context 'basic matrix with vertical bar' do
|
|
179
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'matrix_with_vertical_bar.xml') }
|
|
180
|
+
|
|
181
|
+
it 'outputs correct latex' do
|
|
182
|
+
# actual result: \left|\begin{array}{cc}11& 22\\ 33& 44\\ 55& 66\end{array}\right|
|
|
183
|
+
expect(subject).to eq('\left|\begin{array}{cc}11& 22\\\\ 33& 44\\\\ 55& 66\end{array}\right|')
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
context 'basic matrix with square brackets' do
|
|
188
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'matrix_square_brackets.xml') }
|
|
189
|
+
|
|
190
|
+
it 'outputs correct latex' do
|
|
191
|
+
# actual result: \left[\begin{array}{cc}11& 12\\ 21& 22\\ 31& 32\end{array}\right]
|
|
192
|
+
expect(subject).to eq('\left[\begin{array}{cc}11& 12\\\\ 21& 22\\\\ 31& 32\end{array}\right]')
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
context 'basic matrix with parenthesis' do
|
|
197
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'matrix_parenthesis.xml') }
|
|
198
|
+
|
|
199
|
+
it 'outputs correct latex' do
|
|
200
|
+
# actual result: \left(\begin{array}{ccc}11& 12& 13\\ 21& 22& 23\end{array}\right)
|
|
201
|
+
expect(subject).to eq('\left(\begin{array}{ccc}11& 12& 13\\\\ 21& 22& 23\end{array}\right)')
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
context 'basic piecewise function' do
|
|
206
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'piecewise_function.xml') }
|
|
207
|
+
|
|
208
|
+
it 'outputs correct latex' do
|
|
209
|
+
# actual result: \left\{\begin{array}{ll}11& 22\\ 33& 44\end{array}\right.
|
|
210
|
+
expect(subject).to eq('\left\{\begin{array}{ll}11& 22\\\\ 33& 44\end{array}\right.')
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
context 'basic aligned function' do
|
|
215
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'aligned_equations.xml') }
|
|
216
|
+
|
|
217
|
+
it 'outputs correct latex' do
|
|
218
|
+
# actual result: \begin{array}{rcl}x\operatorname ~ +~ 2y& =& 25\\ 3x\operatorname ~ +\, 6y& =& 20\end{array}
|
|
219
|
+
expect(subject).to eq(
|
|
220
|
+
'\begin{array}{rcl}x\operatorname ~ +~ 2y& =& 25\\\\ 3x\operatorname ~ +\, 6y& =& 20\end{array}'
|
|
221
|
+
)
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
context 'basic parenthesis' do
|
|
226
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'parenthesis.xml') }
|
|
227
|
+
|
|
228
|
+
it 'outputs correct latex' do
|
|
229
|
+
# actual result: \left(www\right)
|
|
230
|
+
expect(subject).to eq('\left(www\right)')
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
context 'basic double vertical bars' do
|
|
235
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'double_vertical_bars.xml') }
|
|
236
|
+
|
|
237
|
+
it 'outputs correct latex' do
|
|
238
|
+
# actual result: \left\|eeee\right\|
|
|
239
|
+
expect(subject).to eq('\left\|eeee\right\|')
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
context 'basic matrix with curly brakets' do
|
|
244
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'matrix_curly_brackets.xml') }
|
|
245
|
+
|
|
246
|
+
it 'outputs correct latex' do
|
|
247
|
+
# actual result: \left\{\begin{array}{cc}11& 22\\ 33& 44\\ 55& 66\end{array}\right\}
|
|
248
|
+
expect(subject).to eq('\left\{\begin{array}{cc}11& 22\\\\ 33& 44\\\\ 55& 66\end{array}\right\}')
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
context 'basic matrix with top curly braket' do
|
|
253
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'matrix_top_curly_bracket.xml') }
|
|
254
|
+
|
|
255
|
+
it 'outputs correct latex' do
|
|
256
|
+
# actual result: \overbrace{\begin{array}{ccc}11& 22& 33\\ aa& bb& cc\end{array}}
|
|
257
|
+
expect(subject).to eq('\overbrace{\begin{array}{ccc}11& 22& 33\\\\ aa& bb& cc\end{array}}')
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
context 'basic matrix with bottom curly braket' do
|
|
262
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'matrix_bottom_curly_bracket.xml') }
|
|
263
|
+
|
|
264
|
+
it 'outputs correct latex' do
|
|
265
|
+
# actual result: \underbrace{\begin{array}{ccc}11& 22& 33\\ aa& bb& cc\end{array}}
|
|
266
|
+
expect(subject).to eq('\underbrace{\begin{array}{ccc}11& 22& 33\\\\ aa& bb& cc\end{array}}')
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
context 'basic top parenthesis' do
|
|
271
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'top_parenthesis.xml') }
|
|
272
|
+
|
|
273
|
+
it 'outputs correct latex' do
|
|
274
|
+
# actual result: \overset{\frown }{2233}
|
|
275
|
+
expect(subject).to eq('\overset{\frown }{2233}')
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
context 'basic bottom parenthesis' do
|
|
280
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'bottom_parenthesis.xml') }
|
|
281
|
+
|
|
282
|
+
it 'outputs correct latex' do
|
|
283
|
+
# actual result: \underset{\smile }{abcde}
|
|
284
|
+
expect(subject).to eq('\underset{\smile }{abcde}')
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
context 'basic vector accent' do
|
|
289
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'vector_accent.xml') }
|
|
290
|
+
|
|
291
|
+
it 'outputs correct latex' do
|
|
292
|
+
# actual result: \overset{\rightharpoonup }{vector}
|
|
293
|
+
expect(subject).to eq('\overset{\rightharpoonup }{vector}')
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
context 'basic arrow accent' do
|
|
298
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'arrow_accent.xml') }
|
|
299
|
+
|
|
300
|
+
it 'outputs correct latex' do
|
|
301
|
+
# actual result: \overset{\rightarrow }{abcd}
|
|
302
|
+
expect(subject).to eq('\overset{\rightarrow }{abcd}')
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
context 'basic left right arrow accent' do
|
|
307
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'left_right_arrow_accent.xml') }
|
|
308
|
+
|
|
309
|
+
it 'outputs correct latex' do
|
|
310
|
+
# actual result: \overset{\leftrightarrow }{abcde}
|
|
311
|
+
expect(subject).to eq('\overset{\leftrightarrow }{abcde}')
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
context 'basic enclose left' do
|
|
316
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'enclose_left.xml') }
|
|
317
|
+
|
|
318
|
+
it 'outputs correct latex' do
|
|
319
|
+
# actual result: \left|abcde\right.
|
|
320
|
+
expect(subject).to eq('\left|abcde\right.')
|
|
321
|
+
end
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
context 'basic enclose right' do
|
|
325
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'enclose_right.xml') }
|
|
326
|
+
|
|
327
|
+
it 'outputs correct latex' do
|
|
328
|
+
# actual result: \left.{eeee}\right|
|
|
329
|
+
expect(subject).to eq('\left.{eeee}\right|')
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
context 'basic enclose box matrix' do
|
|
334
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'enclose_box_matrix.xml') }
|
|
335
|
+
|
|
336
|
+
it 'outputs correct latex' do
|
|
337
|
+
# actual result: \boxed{\begin{array}{ccc}11& 22& 33\\ 44& 55& 66\end{array}}
|
|
338
|
+
expect(subject).to eq('\boxed{\begin{array}{ccc}11& 22& 33\\\\ 44& 55& 66\end{array}}')
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
context 'basic sum with superscript and subscript' do
|
|
343
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'sum_super_sub.xml') }
|
|
344
|
+
|
|
345
|
+
it 'outputs correct latex' do
|
|
346
|
+
# actual result: {\textstyle\sum _{67}^{12}}
|
|
347
|
+
expect(subject).to eq('{\textstyle\sum _{67}^{12}}')
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
context 'basic sum with over and under' do
|
|
352
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'sum_over_under.xml') }
|
|
353
|
+
|
|
354
|
+
it 'outputs correct latex' do
|
|
355
|
+
# actual result: \sum _{aa}^{bb}
|
|
356
|
+
expect(subject).to eq('\sum _{aa}^{bb}')
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
context 'basic definite integral with differential' do
|
|
361
|
+
let(:mathml_path) { File.join(fixtures_path, 'basic', 'definite_integral_with_differential.xml') }
|
|
362
|
+
|
|
363
|
+
it 'outputs correct latex' do
|
|
364
|
+
# actual result: {\int }_{aa}^{bb}cc\operatorname dx
|
|
365
|
+
expect(subject).to eq('{\int }_{aa}^{bb}cc\operatorname dx')
|
|
366
|
+
end
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
describe 'complex latex' do
|
|
371
|
+
context 'sum with nested matrixes' do
|
|
372
|
+
let(:mathml_path) { File.join(fixtures_path, 'complex', 'sum_with_nested_matrix.xml') }
|
|
373
|
+
|
|
374
|
+
it 'outputs correct latex' do
|
|
375
|
+
expect(subject).to eq(
|
|
376
|
+
'{\textstyle\sum _{\left|\begin{array}{ccc}1& 2& 3\\\\ 4& \left\{\begin{array}'\
|
|
377
|
+
'{l}11\\\\ \left[\begin{array}{ccc}1& 2& 3\\\\ 4& 5& {\int }_{a}^{b}x\operatorname'\
|
|
378
|
+
' dx\end{array}\right]\end{array}\right.& 6\end{array}\right|}}'
|
|
379
|
+
)
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
end
|