Convert MathML to SVG using PhantomJS

1,185 views
Skip to first unread message

ansh...@gmail.com

unread,
May 20, 2013, 6:04:58 PM5/20/13
to mathja...@googlegroups.com
Hi

I am trying to convert MathML to SVG given just MathML. Example given a file like this:

<script type="math/mml">
<math>
    <mrow>
      <mi>a</mi>
      <mo>&InvisibleTimes;</mo>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mi>b</mi>
      <mo>&InvisibleTimes; </mo>
      <mi>x</mi>
      <mo>+</mo>
      <mi>c</mi>
    </mrow>
</math>
</script>

I want to convert this into an SVG using MathJax without opening it in a browser.
My current approach is to use PhantomJS to add this MathML code to an HTML page that contains a reference to the MathJax JS and then try to open it. But PhantomJS wont replicate the browser running the MathJax JS. 

I was thinking, if i can give the MathML to the MathJax script as an argument using phantomJS and generate an SVG output file? Or is there something wrong I am doing with my first approach?

Thanks,
Anshul Bhatnagar

Peter Krautzberger

unread,
May 20, 2013, 8:17:36 PM5/20/13
to mathja...@googlegroups.com
Have you looked at this project? https://github.com/agrbin/svgtex

Peter.
> --
> You received this message because you are subscribed to the Google Groups
> "MathJax Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mathjax-user...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Davide P. Cervone

unread,
May 20, 2013, 8:38:50 PM5/20/13
to mathja...@googlegroups.com
Have you looked at the code I provided at


that does something similar for TeX code (to SVG)?  There is no reason why a similar process shouldn't work for MathML rather than TeX.

Davide


Anshul Bhatnagar

unread,
May 20, 2013, 9:32:48 PM5/20/13
to mathja...@googlegroups.com
Thanks guys. I had gone through these and was trying to implement something similar. As it turns out, the problem was with my lack of PhantomJS experience. I was put the page.onAlert() and page.evaluate() outside the page.open(). So they were never getting called.


--
You received this message because you are subscribed to a topic in the Google Groups "MathJax Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mathjax-users/C8DNAX9KwKo/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mathjax-user...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Thank you and regards,

Anshul Bhatnagar

Davide P. Cervone

unread,
May 21, 2013, 6:08:06 AM5/21/13
to mathja...@googlegroups.com
I hope that means you have gotten it to work!

Best of luck.

Davide
Reply all
Reply to author
Forward
0 new messages