75
75
def parse(string, message)
76
string = string.to_str
76
str = as_bytes(string.to_str)
77
77
self.class.semaphore.synchronize do
78
raise Itex2MML::Error unless Itex2MML.send(message, string, string.length) == 0
79
Itex2MML.itex2MML_output
78
raise Itex2MML::Error unless Itex2MML.send(message, str, str.length) == 0
79
as_utf8(Itex2MML.itex2MML_output)
83
if "".respond_to?(:force_encoding)
85
string.force_encoding("ASCII-8BIT")
93
if "".respond_to?(:force_encoding)
95
string.force_encoding("UTF-8")
121
142
def test_inline_utf8
122
143
itex = Itex2MML::Parser.new
123
assert_equal("ecuasi\303\263n <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("ecuasi\303\263n $\\sin(x)$"))
144
s = "".respond_to?(:force_encoding) ? "\u00F3" : "\303\263"
145
assert_equal("ecuasi"+ s + "n <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'>" +
146
"<mi>sin</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></math>",
147
itex.html_filter("ecuasi\303\263n $\\sin(x)$"))
126
150
def test_inline_utf8_inline
127
151
itex = Itex2MML::Parser.new
128
152
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)$"))
155
def test_utf8_in_svg_foreignObject
156
itex = Itex2MML::Parser.new
157
s = "".respond_to?(:force_encoding) ? "\u2032" : "\342\200\262"
158
assert_equal("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>g" +
159
"</mi><mo>′</mo><mo>=</mo><semantics><annotation-xml encoding=\"SVG1.1\"><svg w" +
160
"idth='40' height='40' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3." +
161
"org/1999/xlink'><foreignObject height='19' width='20' font-size='16' y='0' x='0'><ma" +
162
"th display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>g</mi><mo>" +
163
s + "</mo></math></foreignObject></svg></annotation-xml></semantics></math>",
164
itex.filter("$g' = \\begin{svg}<svg width='40' height='40' xmlns='http://www.w3.org/20" +
165
"00/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><foreignObject height='19' width='" +
166
"20' font-size='16' y='0' x='0'><math display='inline' xmlns='http://www.w3.org/1998/M" +
167
"ath/MathML'><mi>g</mi><mo>\342\200\262</mo></math></foreignObject></svg>\\end{svg}$"))