Kaiido / SVG2Bitmap

A small function using the ability of HTMLCanvas element to rasterize svg images
MIT License
18 stars 8 forks source link

Doesnt seem to work with mathjax #1

Closed grofit closed 8 years ago

grofit commented 8 years ago

I am using Latex style mathjax notation which outputs svgs and when converting it to an image it just seems to be an empty image of the right size.

The mathjax content would look like:

<span class="latex-section">
    <span class="MathJax_Preview"></span>
    <div class="MathJax_SVG_Display" style="text-align: center;">
        <span class="MathJax_SVG" id="MathJax-Element-2-Frame" role="math" style="font-size: 150%; display: inline-block;">
        <svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.13ex" height="2.13ex" viewBox="-34 -690.6 892 914.3" style="vertical-align: -0.592ex; margin: 1px 0ex 1px -0.118ex;"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">
            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#MJMATHI-70" x="0" y="0"></use>
            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#MJMATHI-69" x="508" y="0"></use>
            </g>
        </svg>
        </span>
    </div>
    <script type="math/tex; mode=display" id="MathJax-Element-2">
    pi
    </script>
</span>

I am not really that versed in SVG but the actual content seems to be sensible enough, so is there anything wrong with the SVG listed above or is there a problem with the lib?

I have tried passing in the svg element and that shows a completely transparent png, same with the root span or containing div etc.

Kaiido commented 8 years ago

Yes, MathJax seems to use setAttributeNS to set the xlink:href attributes. We only did check for attributes['xlink:href'] in some part of the code. It should now be fixed.

Also note that SVG2Bitmap is still in alpha-pre-release.

Anyway, thanks for your feedback, don't hesitate to push more issues, and I hope you enjoy this little script :-)