git.iko.soy/typeable/pandoc
on master help sign in
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.

commitda72d0f412559fa0ee719329e3de61d387a31ceb authorJesse Rosenthal <jrosenthal@jhu.edu> dateThu 11 Jan 2018, 17:05 (9 years ago) parent206545c
1 file changed+10−2
src/Text/Pandoc/Writers/Powerpoint.hs+10−2
src/Text/Pandoc/Writers/Powerpoint.hs+10−2
@@ -146,6 +146,8 @@ data WriterState = WriterState { stLinkIds :: M.Map Int (M.Map Int (URL, String)
146146 , stMediaIds :: M.Map Int [MediaInfo]
147147 , stMediaGlobalIds :: M.Map FilePath Int
148148 , stNoteIds :: M.Map Int [Block]
149+ -- anchors in the current slide
150+ , stCurSlideAnchors :: M.Map String Int
149151 } deriving (Show, Eq)
150152
151153instance Default WriterState where
@@ -153,6 +155,7 @@ instance Default WriterState where
153155 , stMediaIds = mempty
154156 , stMediaGlobalIds = mempty
155157 , stNoteIds = mempty
158+ , stCurSlideAnchors = mempty
156159 }
157160
158161type P m = ReaderT WriterEnv (StateT WriterState m)
@@ -606,6 +609,8 @@ blocksToSlide blks = do
606609 slideLevel <- asks envSlideLevel
607610 blocksToSlide' slideLevel blks
608611
612+
613+
609614makeNoteEntry :: Int -> [Block] -> [Block]
610615makeNoteEntry n blks =
611616 let enum = Str (show n ++ ".")
@@ -662,8 +667,11 @@ getMetaSlide = do
662667blocksToPresentation :: PandocMonad m => [Block] -> P m Presentation
663668blocksToPresentation blks = do
664669 blksLst <- splitBlocks blks
665− slides <- mapM blocksToSlide blksLst
666− noteSlides <- makeNotesSlides
670+ slides <- mapM
671+ (\(bs, n) -> local (\st -> st{envCurSlideId = n}) (blocksToSlide bs))
672+ (zip blksLst [1..])
673+ let noteSlidesNum = length blksLst + 1
674+ noteSlides <- local (\st -> st {envCurSlideId = noteSlidesNum}) makeNotesSlides
667675 let slides' = slides ++ noteSlides
668676 metadataslide <- getMetaSlide
669677 presSize <- asks envPresentationSize