gjtorikian / mtex2MML

A Bison grammar to convert TeX math into MathML.
23 stars 14 forks source link

mtex2MML fails for other options than `--inline`/`--display` #47

Closed aslakr closed 8 years ago

aslakr commented 8 years ago

It seems like the only options for mtex2MML that work are the --inline/--display. Testet on Mac OS X (10.11.3) and Ubuntu 14.04.4 LTS:

echo '\sin y'     | build/mtex2MML --inline
echo '\sin y'     | build/mtex2MML --display 
echo '\sin y'     | build/mtex2MML --inline --print-mtex
echo '\sin y'     | build/mtex2MML --display --print-mtex
echo '$\sin y$'   | build/mtex2MML
echo '$$\sin y$$' | build/mtex2MML
echo '\(\sin y\)' | build/mtex2MML
echo '\[\sin y\]' | build/mtex2MML
echo '$\sin y$'   | build/mtex2MML --use-dollar
echo '$$\sin y$$' | build/mtex2MML --use-double
echo '\(\sin y\)' | build/mtex2MML --use-parens
echo '\[\sin y\]' | build/mtex2MML --use-brackets

I get this (on OS X):

% echo '\sin y'     | build/mtex2MML --inline
<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mi>y</mi></mrow><annotation encoding='application/x-tex'>\sin y
</annotation></semantics></math>
% echo '\sin y'     | build/mtex2MML --display 
<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mi>y</mi></mrow><annotation encoding='application/x-tex'>\sin y
</annotation></semantics></math>
% echo '\sin y'     | build/mtex2MML --inline --print-mtex
$\sin y
$
mtex2MML: mtex parser failed to generate MathML from mtex!
mtex2MML(87165,0x7fff78174000) malloc: *** error for object 0xb000000000000000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
[1]    87164 done       echo '\sin y' | 
       87165 abort      build/mtex2MML --inline --print-mtex
% echo '\sin y'     | build/mtex2MML --display --print-mtex
$$\sin y
$$
mtex2MML: mtex parser failed to generate MathML from mtex!
mtex2MML(87169,0x7fff78174000) malloc: *** error for object 0x8000000000000000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
[1]    87168 done       echo '\sin y' | 
       87169 abort      build/mtex2MML --display --print-mtex
% echo '$\sin y$'   | build/mtex2MML
% echo '$$\sin y$$' | build/mtex2MML
% echo '\(\sin y\)' | build/mtex2MML
% echo '\[\sin y\]' | build/mtex2MML
% echo '$\sin y$'   | build/mtex2MML --use-dollar
% echo '$$\sin y$$' | build/mtex2MML --use-double
% echo '\(\sin y\)' | build/mtex2MML --use-parens
% echo '\[\sin y\]' | build/mtex2MML --use-brackets

Compared to the old itex2MML:

echo -n '\sin y'     | itex2MML --inline
echo -n '\sin y'     | itex2MML --display 
echo -n '\sin y'     | itex2MML --inline --print-itex
echo -n '\sin y'     | itex2MML --display --print-itex
echo -n '$\sin y$'   | itex2MML
echo -n '$$\sin y$$' | itex2MML
echo -n '\(\sin y\)' | itex2MML
echo -n '\[\sin y\]' | itex2MML

which give the following results:

% echo '\sin y'     | itex2MML --inline
<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mi>y</mi></mrow><annotation encoding='application/x-tex'>\sin y
</annotation></semantics></math>
% echo '\sin y'     | itex2MML --display 
<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mi>y</mi></mrow><annotation encoding='application/x-tex'>\sin y
</annotation></semantics></math>
% echo '\sin y'     | itex2MML --inline --print-itex
$\sin y
$
<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mi>y</mi></mrow><annotation encoding='application/x-tex'>\sin y
</annotation></semantics></math>
% echo '\sin y'     | itex2MML --display --print-itex
$$\sin y
$$
<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mi>y</mi></mrow><annotation encoding='application/x-tex'>\sin y
</annotation></semantics></math>
% echo '$\sin y$'   | itex2MML
<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mi>y</mi></mrow><annotation encoding='application/x-tex'>\sin y</annotation></semantics></math>
% echo '$$\sin y$$' | itex2MML
<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mi>y</mi></mrow><annotation encoding='application/x-tex'>\sin y</annotation></semantics></math>
% echo '\(\sin y\)' | itex2MML
\(\sin y\)
% echo '\[\sin y\]' | itex2MML
<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mi>y</mi></mrow><annotation encoding='application/x-tex'>\sin y</annotation></semantics></math>
gjtorikian commented 8 years ago

Bummer! I'll check it out.