108
108
def test_inline_html
109
109
itex = Itex2MML::Parser.new
110
assert_equal("Inline: <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.html_filter('Inline: $\sin(x)$'))
110
assert_equal("Inline: <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding='application/x-tex'>\\sin(x)</annotation></semantics></math>", itex.html_filter('Inline: $\sin(x)$'))
114
114
itex = Itex2MML::Parser.new
115
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.filter('Inline: $\sin(x)$'))
115
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding='application/x-tex'>\\sin(x)</annotation></semantics></math>", itex.filter('Inline: $\sin(x)$'))
118
118
def test_inline_inline
119
119
itex = Itex2MML::Parser.new
120
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.inline_filter('\sin(x)'))
120
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding='application/x-tex'>\\sin(x)</annotation></semantics></math>", itex.inline_filter('\sin(x)'))
123
123
def test_block_html
124
124
itex = Itex2MML::Parser.new
125
assert_equal("Block: <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.html_filter('Block: $$\sin(x)$$'))
125
assert_equal("Block: <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding='application/x-tex'>\\sin(x)</annotation></semantics></math>", itex.html_filter('Block: $$\sin(x)$$'))
129
129
itex = Itex2MML::Parser.new
130
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.filter('Block: $$\sin(x)$$'))
130
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding='application/x-tex'>\\sin(x)</annotation></semantics></math>", itex.filter('Block: $$\sin(x)$$'))
133
133
def test_block_block
134
134
itex = Itex2MML::Parser.new
135
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.block_filter('\sin(x)'))
135
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding='application/x-tex'>\\sin(x)</annotation></semantics></math>", itex.block_filter('\sin(x)'))
138
138
def test_inline_utf8
139
139
itex = Itex2MML::Parser.new
140
140
s = "".respond_to?(:force_encoding) ? "\u00F3" : "\303\263"
141
141
assert_equal("ecuasi"+ s + "n <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'>" +
142
"<mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>",
142
"<semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding='application/x-tex'>\\sin(x)</annotation></semantics></math>",
143
143
itex.html_filter("ecuasi\303\263n $\\sin(x)$"))
146
146
def test_inline_utf8_inline
147
147
itex = Itex2MML::Parser.new
148
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>", itex.filter("ecuasi\303\263n $\\sin(x)$"))
148
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding='application/x-tex'>\\sin(x)</annotation></semantics></math>", itex.filter("ecuasi\303\263n $\\sin(x)$"))
151
151
def test_utf8_in_svg_foreignObject
152
152
itex = Itex2MML::Parser.new
153
153
s = "".respond_to?(:force_encoding) ? "\u2032" : "\342\200\262"
154
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>g" +
155
"</mi><mo>′</mo><mo>=</mo><semantics><annotation-xml encoding=\"SVG1.1\"><svg w" +
156
"idth='40' height='40' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3." +
157
"org/1999/xlink'><foreignObject height='19' width='20' font-size='16' y='0' x='0'><ma" +
158
"th display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>g</mi><mo>" +
159
s + "</mo></math></foreignObject></svg></annotation-xml></semantics></math>",
154
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics>" +
155
"<mrow><mi>g</mi><mo>′</mo><mo>=</mo><semantics><annotation-xml encoding=\"SVG1.1\">" +
156
"<svg width='40' height='40' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www" +
157
".w3.org/1999/xlink'><foreignObject height='19' width='20' font-size='16' y='0' x='0'><" +
158
"math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>g</mi><mo>" + s +
159
"</mo></math></foreignObject></svg></annotation-xml></semantics></mrow><annotation enco" +
160
"ding='application/x-tex'>g' = \\begin{svg}<svg width='40' height=&apo" +
161
"s;40' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w" +
162
"3.org/1999/xlink'><foreignObject height='19' width='20'" +
163
" font-size='16' y='0' x='0'><math display=&ap" +
164
"os;inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>g<" +
165
";/mi><mo>" + s + "</mo></math></foreignObject></svg>\\" +
166
"end{svg}</annotation></semantics></math>",
160
167
itex.filter("$g' = \\begin{svg}<svg width='40' height='40' xmlns='http://www.w3.org/20" +
161
168
"00/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><foreignObject height='19' width='" +
162
169
"20' font-size='16' y='0' x='0'><math display='inline' xmlns='http://www.w3.org/1998/M" +