Class: Itex2MMLTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/itextomml.rb

Instance Method Summary collapse

Instance Method Details

#test_blockObject



128
129
130
131
# File 'lib/itextomml.rb', line 128

def test_block
  itex = Itex2MML::Parser.new
  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)$$'))
end

#test_block_blockObject



133
134
135
136
# File 'lib/itextomml.rb', line 133

def test_block_block
  itex = Itex2MML::Parser.new
  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)'))
end

#test_block_htmlObject



123
124
125
126
# File 'lib/itextomml.rb', line 123

def test_block_html
  itex = Itex2MML::Parser.new
  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)$$'))
end

#test_inlineObject



113
114
115
116
# File 'lib/itextomml.rb', line 113

def test_inline
  itex = Itex2MML::Parser.new
  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)$'))
end

#test_inline_htmlObject



108
109
110
111
# File 'lib/itextomml.rb', line 108

def test_inline_html
  itex = Itex2MML::Parser.new
  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)$'))
end

#test_inline_inlineObject



118
119
120
121
# File 'lib/itextomml.rb', line 118

def test_inline_inline
  itex = Itex2MML::Parser.new
  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)'))
end

#test_inline_utf8Object



138
139
140
141
142
143
144
# File 'lib/itextomml.rb', line 138

def test_inline_utf8
  itex = Itex2MML::Parser.new
  s = "".respond_to?(:force_encoding) ? "\u00F3" : "\303\263"
  assert_equal("ecuasi"+ s + "n <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("ecuasi\303\263n $\\sin(x)$"))
end

#test_inline_utf8_inlineObject



146
147
148
149
# File 'lib/itextomml.rb', line 146

def test_inline_utf8_inline
  itex = Itex2MML::Parser.new
  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)$"))
end

#test_utf8_in_svg_foreignObjectObject



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/itextomml.rb', line 151

def test_utf8_in_svg_foreignObject
  itex = Itex2MML::Parser.new
  s = "".respond_to?(:force_encoding) ? "\u2032" : "\342\200\262"
  assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics>" +
      "<mrow><mi>g</mi><mo>&prime;</mo><mo>=</mo><semantics><annotation-xml encoding=\"SVG1.1\">" +
      "<svg width='40' height='40' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www" +
      ".w3.org/1999/xlink'><foreignObject height='19' width='20' font-size='16' y='0' x='0'><" +
      "math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>g</mi><mo>" + s +
      "</mo></math></foreignObject></svg></annotation-xml></semantics></mrow><annotation enco" +
      "ding='application/x-tex'>g&apos; = \\begin{svg}&lt;svg width=&apos;40&apos; height=&apo" +
      "s;40&apos; xmlns=&apos;http://www.w3.org/2000/svg&apos; xmlns:xlink=&apos;http://www.w" +
      "3.org/1999/xlink&apos;&gt;&lt;foreignObject height=&apos;19&apos; width=&apos;20&apos;" +
      " font&#x2d;size=&apos;16&apos; y=&apos;0&apos; x=&apos;0&apos;&gt;&lt;math display=&ap" +
      "os;inline&apos; xmlns=&apos;http://www.w3.org/1998/Math/MathML&apos;&gt;&lt;mi&gt;g&lt" +
      ";/mi&gt;&lt;mo&gt;" + s + "&lt;/mo&gt;&lt;/math&gt;&lt;/foreignObject&gt;&lt;/svg&gt;\\" +
      "end{svg}</annotation></semantics></math>",
    itex.filter("$g' = \\begin{svg}<svg width='40' height='40' xmlns='http://www.w3.org/20" +
      "00/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><foreignObject height='19' width='" +
      "20' font-size='16' y='0' x='0'><math display='inline' xmlns='http://www.w3.org/1998/M" +
      "ath/MathML'><mi>g</mi><mo>\342\200\262</mo></math></foreignObject></svg>\\end{svg}$"))
end