itextomml 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -99,3 +99,76 @@ module Itex2MML
99
99
  end
100
100
  end
101
101
 
102
+ ## Unit Tests ##
103
+ if __FILE__ == $0
104
+ require 'test/unit'
105
+
106
+ class Itex2MMLTest < Test::Unit::TestCase
107
+
108
+ def test_inline_html
109
+ itex = Itex2MML::Parser.new
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)$'))
111
+ end
112
+
113
+ def test_inline
114
+ itex = Itex2MML::Parser.new
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)$'))
116
+ end
117
+
118
+ def test_inline_inline
119
+ itex = Itex2MML::Parser.new
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)'))
121
+ end
122
+
123
+ def test_block_html
124
+ itex = Itex2MML::Parser.new
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)$$'))
126
+ end
127
+
128
+ def test_block
129
+ itex = Itex2MML::Parser.new
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)$$'))
131
+ end
132
+
133
+ def test_block_block
134
+ itex = Itex2MML::Parser.new
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)'))
136
+ end
137
+
138
+ def test_inline_utf8
139
+ itex = Itex2MML::Parser.new
140
+ s = "".respond_to?(:force_encoding) ? "\u00F3" : "\303\263"
141
+ assert_equal("ecuasi"+ s + "n <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'>" +
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
+ itex.html_filter("ecuasi\303\263n $\\sin(x)$"))
144
+ end
145
+
146
+ def test_inline_utf8_inline
147
+ itex = Itex2MML::Parser.new
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)$"))
149
+ end
150
+
151
+ def test_utf8_in_svg_foreignObject
152
+ itex = Itex2MML::Parser.new
153
+ s = "".respond_to?(:force_encoding) ? "\u2032" : "\342\200\262"
154
+ assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics>" +
155
+ "<mrow><mi>g</mi><mo>&prime;</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&apos; = \\begin{svg}&lt;svg width=&apos;40&apos; height=&apo" +
161
+ "s;40&apos; xmlns=&apos;http://www.w3.org/2000/svg&apos; xmlns:xlink=&apos;http://www.w" +
162
+ "3.org/1999/xlink&apos;&gt;&lt;foreignObject height=&apos;19&apos; width=&apos;20&apos;" +
163
+ " font&#x2d;size=&apos;16&apos; y=&apos;0&apos; x=&apos;0&apos;&gt;&lt;math display=&ap" +
164
+ "os;inline&apos; xmlns=&apos;http://www.w3.org/1998/Math/MathML&apos;&gt;&lt;mi&gt;g&lt" +
165
+ ";/mi&gt;&lt;mo&gt;" + s + "&lt;/mo&gt;&lt;/math&gt;&lt;/foreignObject&gt;&lt;/svg&gt;\\" +
166
+ "end{svg}</annotation></semantics></math>",
167
+ itex.filter("$g' = \\begin{svg}<svg width='40' height='40' xmlns='http://www.w3.org/20" +
168
+ "00/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><foreignObject height='19' width='" +
169
+ "20' font-size='16' y='0' x='0'><math display='inline' xmlns='http://www.w3.org/1998/M" +
170
+ "ath/MathML'><mi>g</mi><mo>\342\200\262</mo></math></foreignObject></svg>\\end{svg}$"))
171
+ end
172
+
173
+ end
174
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itextomml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacques Distler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-13 00:00:00.000000000 Z
11
+ date: 2016-08-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: itextomml provides native Ruby bindings to itex2MML, which converts itex
14
14
  equations to MathML.
@@ -18,16 +18,16 @@ extensions:
18
18
  - ext/extconf.rb
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - README
22
- - ext/extconf.rb
23
- - ext/itex2MML.h
24
21
  - ext/itex2MML_ruby.c
25
22
  - ext/lex.yy.c
26
23
  - ext/y.tab.c
24
+ - ext/itex2MML.h
27
25
  - ext/y.tab.h
28
26
  - lib/itex_stringsupport.rb
29
27
  - lib/itextomml.rb
30
28
  - test/test_itextomml.rb
29
+ - README
30
+ - ext/extconf.rb
31
31
  homepage: http://golem.ph.utexas.edu/~distler/blog/itex2MML.html
32
32
  licenses: []
33
33
  metadata: {}
@@ -38,17 +38,17 @@ require_paths:
38
38
  - ext
39
39
  required_ruby_version: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ">="
41
+ - - '>='
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  requirements: []
50
50
  rubyforge_project:
51
- rubygems_version: 2.2.2
51
+ rubygems_version: 2.0.14
52
52
  signing_key:
53
53
  specification_version: 4
54
54
  summary: Native Ruby bindings to itex2MML.