From da72d0f412559fa0ee719329e3de61d387a31ceb Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Thu, 11 Jan 2018 17:05:04 -0500 Subject: 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. --- src/Text/Pandoc/Writers/Powerpoint.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') 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 -- cgit v1.2.3