Hi all, I have some XML created by a tool called latexml that can convert LaTeX equations to MathML. I am processing the output of this tool as part of a Guile program and will be using it in a website.
The output looks something like this: --8<---------------cut here---------------start------------->8--- <math xmlns=\"http://www.w3.org/1998/Math/MathML\" alttext=\"\\frac{1}{2}\" display=\"block\"> <mfrac> <mn>1</mn> <mn>2</mn> </mfrac> </math> --8<---------------cut here---------------end--------------->8--- I need to convert this output to SXML to integrate it with the rest of the toolchain. Annoyingly, when using xml->sxml, the xmlns attribute is prepended to every non-default element. For example, '(http://www.w3.org/1998/Math/MathML:math ...) [1]. This behavior is undesirable when splicing the MathML into HTML, since HTML doesn't support namespaces and web browsers don't seem to handle elements with colons. The intended conversion is to simply splice the MathML into HTML, sans namespace [2]. xml->sxml has a #:namespaces argument that allows me to alias the URL namespace to something else in the SXML, but it doesn't look like I can alias it to a "nil" namespace that isn't prepended at all. The only option I can think of is to strip the xmlns=blah string from the XML ahead of time. (Because converting to SXML prepends every element, that's a lot harder to fix.) This solution feels rather hacky. Does anyone know of a better way? I don't believe latexml has an option to force HTML-compatible MathML output for individual equations. I'd be surprised if no one else encountered this before. Hopefully I'm missing something. Thanks! :) [1]: (guile) Reading and Writing XML, "SXML elements built from non-default namespaces will have their tags prefixed with their URI." [2]: https://en.wikipedia.org/wiki/MathML#Embedding_MathML_in_HTML/XHTML_files -- Take it easy, Richard Sent Making my computer weirder one commit at a time.