Closed AllenDowney closed 12 years ago
I went ahead and generated class definitions and ztp templates for all of the mathml presentation tags listed here:
http://www.w3.org/TR/MathML2/chapter3.html#presm.summary
Still not sure this is the most elegant solution, but it works.
In TreeCleaner I am using Tralics to translate LaTeX math into MathML. The result is a string of XML, like
I use lxml to parse it; the result is a tree of etree.Element
Then I convert this tree into a tree of DOM.Node
Now, in order for that to get rendered, I am currently adding a new command in Base/LaTeX/Math.py for each MathML tag, for example:
Then I am adding a new template in Renderers/Docbook/book.zpts (maybe it should be in Math.zpts), for example:
This is working, but it seems crazy to add a Command and a template for every MathML tag when they are all doing the same thing. Is there a smarter way to do this?
One option would be to render the entire expression as a string during TreeCleaning, then render the whole thing as one string. In that case I need to do something in the Renderer to treat the string as raw XML and not convert < and > to XML entities.