asciidoctor / asciimath

Asciimath parser
MIT License
24 stars 16 forks source link

accent attribute needs to be respected in processing, for Word #51

Closed opoudjis closed 3 years ago

opoudjis commented 4 years ago

hat p currently renders into MathML as <mover><mi>p</mi><mo>^</mo></mover>. When this is converted into Word, the result is

instead of the desired

Inspecting the Word OOXML XSLT, it turns out that Word expects to see <mover accent="true"><mi>p</mi><mo>^</mo></mover>, in order to render the equation with the its <m:acc> tag. The hat operator of Asciimath is recognised as being of class :accent, but that class is not being propagated into the Asciimath parse.

pepijnve commented 4 years ago

@opoudjis could you give the changes in 49ccf25 a try? This should cause accent="true" and accentunder="true" to get produced on munder, mover, and munderover tags for every symbol that's marked as :accent.

pepijnve commented 4 years ago

Interestingly enough asciimath.js doesn't seem to produce these attributes either. According to MDN only Firefox actually does anything with them. It doesn't cause any problems when adding them though, so no there's no harm in this change.

opoudjis commented 4 years ago

Thank you. It turns out that the Word OOXML stylesheets make a further assumption, that the second argument of mover is an mo, in order to apply the accent conversion:

<xsl:when test="$fAccent = 1 and $ndCur/child::*[2] = mml:mo">

So AsciiMath generates: <mover accent="true"><mrow><mi>p</mi></mrow><mrow><mo>^</mo></mrow></mover> Word expects: <mover accent="true"><mrow><mi>p</mi></mrow><mo>^</mo></mover>

I have already inserted preprocessing to remove the mrow from the second child of an element with accent=true; once I do this, your fix works fine. I am not requesting you to do that preprocessing for Word; I have what I need. Thank you!

pepijnve commented 4 years ago

🙄 I'm still surprised how picky Word is about MathML. They claim to support it but half the valid MathML out there probably doesn't render right...

opoudjis commented 4 years ago

Word's Maths remains a dumpster fire if you look at it closely enough. :-( The latest I've had to deal with is that it completely ignores its own font shift commands; I've had to inject HTML markup to force them to work...

pepijnve commented 4 years ago

I went ahead and added some code to avoid mrow on the accent sub/under and sup/over elements if possible. That logic is Word specific anyway, might as well give it what it wants.

opoudjis commented 4 years ago

You, Pepijn, are a good human being, and it is always a pleasure working with you.

pepijnve commented 4 years ago

☺️ My little contribution to counterbalance all the awfulness of 2020.

opoudjis commented 3 years ago

@pepijnve We can close this issue right?

pepijnve commented 3 years ago

I'm looking to you for the answer there @opoudjis. If the fix is sufficient for you then this can be closed indeed.

opoudjis commented 3 years ago

It is, thank you. Closing!