I run into the exact same problem : the MathML element and descendants is correctly parsed to my prosemirror model, correctly rendered by toDOM, including mathml xml namespace attribute, but is not rendered as MathML : the text content of mathml elements is rendered as plain text. The exact same MathML copied anywhere in the same page but outside prosemirror document is displayed correctly as math.
Any help or pointer would be appreciated !
If something is missing in the question that prevents you from answering, let me know, and I’ll be happy to provide details.
I finally figured out how to make MathML display correctly.
The issue of the browser misinterpreting MathML was caused by the namespace. I wrongly was defining toDOM to output an xmlns="http://www.w3.org/1998/Math/MathML" attribute in the outer math element hoping it would act as a default namespace for its children, but it was not the case.
I still couldn’t find a way to add a default namespace to the math element. However, by prefixing every MathML element in the model created by toDOM with its namespace, the formula displays correctly.
Here is the relevant part of the model
nodes = {
...
math : {
...
toDOM : node => ["http://www.w3.org/1998/Math/MathML math",{...},0],
...
},
mi: {
...
toDOM: node => ["http://www.w3.org/1998/Math/MathML mi", {}, 0],
...
},
// and so on for each mathml element, semantics, mrow, mo, mn,...
}
``