module Text.Pandoc.Writers.Powerpoint (writePowerpoint) where
import Codec.Archive.Zip
import Text.Pandoc.Definition
import Text.Pandoc.Walk
import Text.Pandoc.Class.PandocMonad (PandocMonad, report)
import Text.Pandoc.Options (WriterOptions)
import Text.Pandoc.Writers.Shared (fixDisplayMath)
import Text.Pandoc.Writers.Powerpoint.Presentation (documentToPresentation)
import Text.Pandoc.Writers.Powerpoint.Output (presentationToArchive)
import qualified Data.ByteString.Lazy as BL
writePowerpoint :: (PandocMonad m)
=> WriterOptions
-> Pandoc
-> m BL.ByteString
writePowerpoint :: forall (m :: * -> *).
PandocMonad m =>
WriterOptions -> Pandoc -> m ByteString
writePowerpoint WriterOptions
opts (Pandoc Meta
meta [Block]
blks) = do
let blks' :: [Block]
blks' = forall a b. Walkable a b => (a -> a) -> b -> b
walk Block -> Block
fixDisplayMath [Block]
blks
let (Presentation
pres, [LogMessage]
logMsgs) = WriterOptions -> Pandoc -> (Presentation, [LogMessage])
documentToPresentation WriterOptions
opts (Meta -> [Block] -> Pandoc
Pandoc Meta
meta [Block]
blks')
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report [LogMessage]
logMsgs
Archive
archv <- forall (m :: * -> *).
PandocMonad m =>
WriterOptions -> Meta -> Presentation -> m Archive
presentationToArchive WriterOptions
opts Meta
meta Presentation
pres
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Archive -> ByteString
fromArchive Archive
archv