roniemartinez / latex2mathml

Pure Python library for LaTeX to MathML conversion
MIT License
183 stars 25 forks source link

MathML output contains backslashes #91

Closed ghost closed 4 years ago

ghost commented 4 years ago

When using latex2mathml

$ latex2mathml --version
latex2mathml 2.13.0

I'm finding that with inputs like this:

$ latex2mathml -t '\frac{\tan^{2}x}{1+\sec x}'

latex2mathml is producing outputs like this:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">
    <mrow>
        <mfrac>
            <mrow>
                <msup>
                    <mi>\tan</mi>
                    <mrow>
                        <mn>2</mn>
                    </mrow>
                </msup>
                <mi>x</mi>
            </mrow>
            <mrow>
                <mn>1</mn>
                <mo>&#x0002B;</mo>
                <mi>\sec</mi>
                <mi>x</mi>
            </mrow>
        </mfrac>
    </mrow>
</math>

Now, as you can see, the expressions with trigonometric functions contain backslashes in them. \tan should just be tan. and \sec should just be sec. This happens for every trigonometric operator I've tried, but I can't speak to other operators.

To mitigate this issue, I wrote a script that just pipes latex2mathml's output through sed like this:

#!/usr/bin/env sh
latex2mathml -t "$1" | sed 's|\\||g'

But that's not really the ideal solution.

ghost commented 4 years ago

I also checked the quoting (using " and ') and the output is still the same.

roniemartinez commented 4 years ago

@jordanbancino Kindly update to version 2.14.0

ghost commented 4 years ago

Wow, quick! Awesome, thank you!

roniemartinez commented 2 years ago

@all-contributors please add @ghost for bug

allcontributors[bot] commented 2 years ago

@roniemartinez

I've put up a pull request to add @ghost! :tada: