git.iko.soy/typeable/pandoc
on master help sign in
Docx writer: properly handle display math in spans.
4ec0205John MacFarlane
src/Text/Pandoc/Writers/Docx.hs+6−4
@@ -66,7 +66,8 @@ import Text.Pandoc.Readers.Docx.StyleMap
66import Text.Pandoc.Shared hiding (Element)
66import Text.Pandoc.Shared hiding (Element)
67import Text.Pandoc.Walk
67import Text.Pandoc.Walk
68import Text.Pandoc.Writers.Math
68import Text.Pandoc.Writers.Math
69−import Text.Pandoc.Writers.Shared (fixDisplayMath, metaValueToInlines)
69+import Text.Pandoc.Writers.Shared (isDisplayMath, fixDisplayMath,
70+ metaValueToInlines)
70import Text.Printf (printf)
71import Text.Printf (printf)
71import Text.TeXMath
72import Text.TeXMath
72import Text.XML.Light as XML
73import Text.XML.Light as XML
@@ -915,9 +916,10 @@ blockToOpenXML' opts (Para lst)
915 | null lst && not (isEnabled Ext_empty_paragraphs opts) = return []
916 | null lst && not (isEnabled Ext_empty_paragraphs opts) = return []
916 | otherwise = do
917 | otherwise = do
917 isFirstPara <- gets stFirstPara
918 isFirstPara <- gets stFirstPara
918− paraProps <- getParaProps $ case lst of
919+ let displayMathPara = case lst of
919− [Math DisplayMath _] -> True
920+ [x] -> isDisplayMath x
920− _ -> False
921+ _ -> False
922+ paraProps <- getParaProps displayMathPara
921 bodyTextStyle <- pStyleM "Body Text"
923 bodyTextStyle <- pStyleM "Body Text"
922 let paraProps' = case paraProps of
924 let paraProps' = case paraProps of
923 [] | isFirstPara -> [mknode "w:pPr" []
925 [] | isFirstPara -> [mknode "w:pPr" []
src/Text/Pandoc/Writers/Shared.hs+4−2
@@ -38,6 +38,7 @@ module Text.Pandoc.Writers.Shared (
38 , resetField
38 , resetField
39 , defField
39 , defField
40 , tagWithAttrs
40 , tagWithAttrs
41+ , isDisplayMath
41 , fixDisplayMath
42 , fixDisplayMath
42 , unsmartify
43 , unsmartify
43 , gridTable
44 , gridTable
@@ -187,8 +188,9 @@ tagWithAttrs tag (ident,classes,kvs) = hsep
187 ] <> ">"
188 ] <> ">"
188
189
189isDisplayMath :: Inline -> Bool
190isDisplayMath :: Inline -> Bool
190−isDisplayMath (Math DisplayMath _) = True
191+isDisplayMath (Math DisplayMath _) = True
192+isDisplayMath (Span _ [Math DisplayMath _]) = True
191−isDisplayMath _ = False
193+isDisplayMath _ = False
192
194
193stripLeadingTrailingSpace :: [Inline] -> [Inline]
195stripLeadingTrailingSpace :: [Inline] -> [Inline]
194stripLeadingTrailingSpace = go . reverse . go . reverse
196stripLeadingTrailingSpace = go . reverse . go . reverse