I'm doing some writing where I use MathJax to render the math. I also occasionally include SVG diagrams which are generated dynamically by javascript. Those SVG diagrams occasionally include math.
I'd like the text elements in those SVG diagrams to be rendered using MathJax. I know how to cause the dynamic math to be rendered. However, the mathjax output is in <span>
s which aren't valid SVG and don't show up.
This persists when I configure MathJax to use SVG output mode, though this is perhaps due to an improper use of SVG output mode. I changed by MathJax CDN link to http://cdn.mathjax.org/mathjax/2.1-latest/MathJax.js?config=TeX-AMS-MML_SVG
, which did not produce SVG output. I haven't been able to coax MathJax into actually outputting SVG elements yet.
I've considered using an SVG <foreignObject>
tag which is non-ideal because (to my knowledge) I must specify a width and height, which is inconvenient.
Is there a better way to include MathJax rendered text inside SVG inside HTML?