aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2020-04-30 10:12:52 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2020-04-30 10:12:52 -0400
commit9e7572da1fcc5f7299e92c93f8960e8705d184db (patch)
treef28cffb7bcb20856491062c0af962ed9bab95aa4
parent9c2b659eeb196145f62d8eae0072c279a7c2d751 (diff)
downloadpandoc-9e7572da1fcc5f7299e92c93f8960e8705d184db.tar.gz
PowerPoint writer: write math input verbatim in speaker notes.
OMML in speaker notes would lead to corrupt PowerPoint output. We now output the OMML verbatim as LaTeX in the speaker notes. Closes #6301.
-rw-r--r--src/Text/Pandoc/Writers/Powerpoint/Output.hs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/Powerpoint/Output.hs b/src/Text/Pandoc/Writers/Powerpoint/Output.hs
index 12467048b..656ef6056 100644
--- a/src/Text/Pandoc/Writers/Powerpoint/Output.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint/Output.hs
@@ -106,6 +106,7 @@ data WriterEnv = WriterEnv { envRefArchive :: Archive
-- are no notes for a slide, there will be
-- no entry in the map for it.
, envSpeakerNotesIdMap :: M.Map Int Int
+ , envInSpeakerNotes :: Bool
}
deriving (Show)
@@ -123,6 +124,7 @@ instance Default WriterEnv where
, envContentType = NormalContent
, envSlideIdMap = mempty
, envSpeakerNotesIdMap = mempty
+ , envInSpeakerNotes = False
}
data ContentType = NormalContent
@@ -803,11 +805,14 @@ paraElemToElements (Run rpr s) = do
, mknode "a:t" [] $ T.unpack s
]]
paraElemToElements (MathElem mathType texStr) = do
- res <- convertMath writeOMML mathType (unTeXString texStr)
- case res of
- Right r -> return [mknode "a14:m" [] $ addMathInfo r]
- Left (Str s) -> paraElemToElements (Run def s)
- Left _ -> throwError $ PandocShouldNeverHappenError "non-string math fallback"
+ isInSpkrNotes <- asks envInSpeakerNotes
+ if isInSpkrNotes
+ then paraElemToElements $ Run def $ unTeXString texStr
+ else do res <- convertMath writeOMML mathType (unTeXString texStr)
+ case res of
+ Right r -> return [mknode "a14:m" [] $ addMathInfo r]
+ Left (Str s) -> paraElemToElements (Run def s)
+ Left _ -> throwError $ PandocShouldNeverHappenError "non-string math fallback"
paraElemToElements (RawOOXMLParaElem str) = return [ x | Elem x <- parseXML str ]
@@ -1231,7 +1236,8 @@ spaceParas = intersperse (Paragraph def [])
speakerNotesBody :: PandocMonad m => [Paragraph] -> P m Element
speakerNotesBody paras = do
- elements <- mapM paragraphToElement $ spaceParas $ map removeParaLinks paras
+ elements <- local (\env -> env{envInSpeakerNotes = True}) $
+ mapM paragraphToElement $ spaceParas $ map removeParaLinks paras
let txBody = mknode "p:txBody" [] $
[mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] <> elements
return $