diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2018-01-11 17:05:04 -0500 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2018-01-12 06:56:09 -0500 |
commit | da72d0f412559fa0ee719329e3de61d387a31ceb (patch) | |
tree | 7496901f29b09f2a06f390b2f7fdf1db7730a4da /src | |
parent | 206545c6756f7d4dec4c4761d8e256c2c0dfa33a (diff) | |
download | pandoc-da72d0f412559fa0ee719329e3de61d387a31ceb.tar.gz |
Powerpoint writer: Make the slide number available to the blocks.
For anchors, block-processing functions need to know what slide number
they're in. We make the envCurSlideId available to blocks.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/Powerpoint.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Powerpoint.hs b/src/Text/Pandoc/Writers/Powerpoint.hs index 0ff80bdc9..1509f967f 100644 --- a/src/Text/Pandoc/Writers/Powerpoint.hs +++ b/src/Text/Pandoc/Writers/Powerpoint.hs @@ -146,6 +146,8 @@ data WriterState = WriterState { stLinkIds :: M.Map Int (M.Map Int (URL, String) , stMediaIds :: M.Map Int [MediaInfo] , stMediaGlobalIds :: M.Map FilePath Int , stNoteIds :: M.Map Int [Block] + -- anchors in the current slide + , stCurSlideAnchors :: M.Map String Int } deriving (Show, Eq) instance Default WriterState where @@ -153,6 +155,7 @@ instance Default WriterState where , stMediaIds = mempty , stMediaGlobalIds = mempty , stNoteIds = mempty + , stCurSlideAnchors = mempty } type P m = ReaderT WriterEnv (StateT WriterState m) @@ -606,6 +609,8 @@ blocksToSlide blks = do slideLevel <- asks envSlideLevel blocksToSlide' slideLevel blks + + makeNoteEntry :: Int -> [Block] -> [Block] makeNoteEntry n blks = let enum = Str (show n ++ ".") @@ -662,8 +667,11 @@ getMetaSlide = do blocksToPresentation :: PandocMonad m => [Block] -> P m Presentation blocksToPresentation blks = do blksLst <- splitBlocks blks - slides <- mapM blocksToSlide blksLst - noteSlides <- makeNotesSlides + slides <- mapM + (\(bs, n) -> local (\st -> st{envCurSlideId = n}) (blocksToSlide bs)) + (zip blksLst [1..]) + let noteSlidesNum = length blksLst + 1 + noteSlides <- local (\st -> st {envCurSlideId = noteSlidesNum}) makeNotesSlides let slides' = slides ++ noteSlides metadataslide <- getMetaSlide presSize <- asks envPresentationSize |