Skip to content

Commit aee6b49

Browse files
committed
OMML reader: handle w:ins elements in math.
Previously we skipped these, which meant that content would disappear. Closes #278.
1 parent 72a188e commit aee6b49

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Text/TeXMath/Readers/OMML.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ hasElemName prefix name qn =
9595
data OMathRunElem = TextRun T.Text
9696
| LnBrk
9797
| Tab
98+
| Inserted [OMathRunElem]
9899
deriving Show
99100

100101
data OMathRunTextStyle = NoStyle
@@ -165,6 +166,7 @@ elemToOMathRunElem element
165166
| isElem "w" "br" element = Just LnBrk
166167
| isElem "w" "tab" element = Just Tab
167168
| isElem "w" "sym" element = Just $ TextRun $ getSymChar element
169+
| isElem "w" "ins" element = Just $ Inserted $ mapMaybe elemToOMathRunElem (elChildren element)
168170
| otherwise = Nothing
169171

170172
elemToOMathRunElems :: Element -> Maybe [OMathRunElem]
@@ -180,6 +182,7 @@ oMathRunElemToText :: OMathRunElem -> T.Text
180182
oMathRunElemToText (TextRun s) = s
181183
oMathRunElemToText (LnBrk) = "\n"
182184
oMathRunElemToText (Tab) = "\t"
185+
oMathRunElemToText (Inserted es) = mconcat $ map oMathRunElemToText es
183186

184187
oMathRunElemsToText :: [OMathRunElem] -> T.Text
185188
oMathRunElemsToText = T.concat . map oMathRunElemToText

test/regression/278.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<<< omml
2+
<m:oMath><m:r><w:ins w:id="2" w:author="Tron Su" w:date="2025-12-16T22:06:00Z" w16du:dateUtc="2025-12-16T14:06:00Z"><m:rPr><m:nor/></m:rPr><w:rPr><w:rFonts w:cs="Times New Roman"/><w:sz w:val="28"/></w:rPr><m:t>∆</m:t></w:ins></m:r><m:r><w:ins w:id="3" w:author="Tron Su" w:date="2025-12-16T22:06:00Z" w16du:dateUtc="2025-12-16T14:06:00Z"><w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr><m:t>F</m:t></w:ins></m:r><m:r><w:ins w:id="4" w:author="Tron Su" w:date="2025-12-16T22:06:00Z" w16du:dateUtc="2025-12-16T14:06:00Z"><m:rPr><m:sty m:val="p"/></m:rPr><w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr><m:t>/</m:t></w:ins></m:r><m:sSub><m:sSubPr><m:ctrlPr><w:ins w:id="5" w:author="Tron Su" w:date="2025-12-16T22:06:00Z" w16du:dateUtc="2025-12-16T14:06:00Z"><w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr></w:ins></m:ctrlPr></m:sSubPr><m:e><m:r><w:ins w:id="6" w:author="Tron Su" w:date="2025-12-16T22:06:00Z" w16du:dateUtc="2025-12-16T14:06:00Z"><w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr><m:t>F</m:t></w:ins></m:r></m:e><m:sub><m:r><w:ins w:id="7" w:author="Tron Su" w:date="2025-12-16T22:06:00Z" w16du:dateUtc="2025-12-16T14:06:00Z"><w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr><m:t>0</m:t></w:ins></m:r></m:sub></m:sSub></m:oMath>
3+
>>> tex
4+
\mathrm{\Delta}F/F_{0}

0 commit comments

Comments
 (0)