Underbar Items without m:pos disappear
Meimax opened this issue · 6 comments
According to the specification of omml, a m:pos element defaults to "bot", if no value is given (https://standards.iso.org/ittf/PubliclyAvailableStandards/c071691_ISO_IEC_29500-1_2016.zip, 22.1.2.84):
22.1.2.84 pos (Position)
This element specifies the position of the bar or group character in the parent object; the default is bot.
Whether the element is absent or present without the val attribute, the default of the val attribute is bot.
At the moment bar items (m:bar
) without a m:pos
element are set to Nothing
,
texmath/src/Text/TeXMath/Readers/OMML.hs
Line 261 in d9013d8
Example: Underbar.txt
With
cat .\Underbar.txt | texmath --from=omml --to=tex
, the output is = T = \overline{T}
, but the expected output would be either \underbar{T} = T = \overline{T}
or \underline{T} = T = \overline{T}
to match the word file.
Maybe a solution would be to just set the bot
case as the default, changing
case pos of
"top" -> Just [EOver False baseExp (ESymbol TOver "\773")]
"bot" -> Just [EUnder False baseExp (ESymbol TUnder "\818")]
_ -> Nothing
to
case pos of
"top" -> Just [EOver False baseExp (ESymbol TOver "\773")]
_ -> Just [EUnder False baseExp (ESymbol TUnder "\818")]
Sounds like a good change. Would you like to submit a PR? (And perhaps add a comment in the source that explains?)
This pull request didn't fully fix the issue. If the m:pos element is not there, it currently still deletes the baseExp:
<m:bar>
<m:barPr>
<m:pos m:val=""/>
<m:ctrlPr>
</m:ctrlPr>
</m:barPr>
<m:e>
<m:r>
<m:t>T</m:t>
</m:r>
</m:e>
</m:bar>
this evaluates correctly, but if you delete either only the val attribute or the pos element:
<m:bar>
<m:barPr>
<m:pos/> <-- or without this line -->
<m:ctrlPr>
</m:ctrlPr>
</m:barPr>
<m:e>
<m:r>
<m:t>T</m:t>
</m:r>
</m:e>
</m:bar>
the expression is not there at all.
Unfortunately I do not know how to fix this myself.
I just pushed a change that I think will fix this. If you can test, that would be great. This change allows m:pos to be missing or to have an empty attribute. In fact it allows the whole bar:Pr element to be missing.
It works in all of these cases. Thank you.
Thank you for this fix! Is this change already included in the latest pandoc?
No, it will be in the next release; for now you could try a nightly.