@@ -113,8 +113,20 @@ instance Default WriterState where
113 , stLog = []
113 , stLog = []
116+metadataSlideId :: SlideId
117+metadataSlideId = SlideId "Metadata"
119+tocSlideId :: SlideId
120+tocSlideId = SlideId "TOC"
122+endNotesSlideId :: SlideId
123+endNotesSlideId = SlideId "EndNotes"
116reservedSlideIds :: S.Set SlideId
125reservedSlideIds :: S.Set SlideId
117−reservedSlideIds = S.fromList [SlideId "EndNotes"]
126+reservedSlideIds = S.fromList [ metadataSlideId
119uniqueSlideId' :: Integer -> S.Set SlideId -> String -> SlideId
131uniqueSlideId' :: Integer -> S.Set SlideId -> String -> SlideId
120uniqueSlideId' n idSet s =
132uniqueSlideId' n idSet s =
@@ -329,7 +341,8 @@ inlineToParElems (Note blks) = do
329 lst -> maximum lst
341 lst -> maximum lst
330 curNoteId = maxNoteId + 1
342 curNoteId = maxNoteId + 1
331 modify $ \st -> st { stNoteIds = M.insert curNoteId blks notes }
343 modify $ \st -> st { stNoteIds = M.insert curNoteId blks notes }
344+ local (\env -> env{envRunProps = (envRunProps env){rLink = Just $ InternalTarget endNotesSlideId}}) $
332− inlineToParElems $ Superscript [Str $ show curNoteId]
345+ inlineToParElems $ Superscript [Str $ show curNoteId]
333inlineToParElems (Span _ ils) = concatMapM inlineToParElems ils
346inlineToParElems (Span _ ils) = concatMapM inlineToParElems ils
334inlineToParElems (RawInline _ _) = return []
347inlineToParElems (RawInline _ _) = return []
335inlineToParElems _ = return []
348inlineToParElems _ = return []
@@ -672,13 +685,12 @@ getMetaSlide = do
673 authors <- mapM inlinesToParElems $ docAuthors meta
686 authors <- mapM inlinesToParElems $ docAuthors meta
674 date <- inlinesToParElems $ docDate meta
687 date <- inlinesToParElems $ docDate meta
675− sldId <- asks envCurSlideId
676 if null title && null subtitle && null authors && null date
688 if null title && null subtitle && null authors && null date
677 then return Nothing
689 then return Nothing
678 else return $
690 else return $
681− sldId
693+ metadataSlideId
682 MetadataSlide { metadataSlideTitle = title
694 MetadataSlide { metadataSlideTitle = title
683 , metadataSlideSubtitle = subtitle
695 , metadataSlideSubtitle = subtitle
684 , metadataSlideAuthors = authors
696 , metadataSlideAuthors = authors
@@ -701,7 +713,7 @@ elementToListItem (Shared.Sec lev _nums (ident,_,_) headerText subsecs) = do
701elementToListItem (Shared.Blk _) = return []
713elementToListItem (Shared.Blk _) = return []
703makeTOCSlide :: [Block] -> Pres Slide
715makeTOCSlide :: [Block] -> Pres Slide
704−makeTOCSlide blks = do
716+makeTOCSlide blks = local (\env -> env{envCurSlideId = tocSlideId}) $ do
705 contents <- BulletList <$> mapM elementToListItem (Shared.hierarchicalize blks)
717 contents <- BulletList <$> mapM elementToListItem (Shared.hierarchicalize blks)
706 meta <- asks envMetadata
718 meta <- asks envMetadata
707 slideLevel <- asks envSlideLevel
719 slideLevel <- asks envSlideLevel
@@ -787,9 +799,7 @@ replaceAnchor pe = return pe
787blocksToPresentation :: [Block] -> Pres Presentation
799blocksToPresentation :: [Block] -> Pres Presentation
788blocksToPresentation blks = do
800blocksToPresentation blks = do
789 opts <- asks envOpts
801 opts <- asks envOpts
790− let metadataStartNum = 1
791 metadataslides <- maybeToList <$> getMetaSlide
802 metadataslides <- maybeToList <$> getMetaSlide
792− let tocStartNum = metadataStartNum + length metadataslides
793 -- As far as I can tell, if we want to have a variable-length toc in
803 -- As far as I can tell, if we want to have a variable-length toc in
794 -- the future, we'll have to make it twice. Once to get the length,
804 -- the future, we'll have to make it twice. Once to get the length,
795 -- and a second time to include the notes slide. We can't make the
805 -- and a second time to include the notes slide. We can't make the
@@ -800,18 +810,14 @@ blocksToPresentation blks = do
800 -- For now, though, since the TOC slide is only length 1, if it
810 -- For now, though, since the TOC slide is only length 1, if it
801 -- exists, we'll just get the length, and then come back to make the
811 -- exists, we'll just get the length, and then come back to make the
802 -- slide later
812 -- slide later
803− let tocSlidesLength = if writerTableOfContents opts then 1 else 0
804− let bodyStartNum = tocStartNum + tocSlidesLength
805 blksLst <- splitBlocks blks
813 blksLst <- splitBlocks blks
807 bodySlideIds <- mapM
814 bodySlideIds <- mapM
808 (\n -> runUniqueSlideId $ "BodySlide" ++ show n)
815 (\n -> runUniqueSlideId $ "BodySlide" ++ show n)
809− ([1..] :: [Integer])
816+ (take (length blksLst) [1..] :: [Integer])
810 bodyslides <- mapM
817 bodyslides <- mapM
811 (\(bs, ident) ->
818 (\(bs, ident) ->
812 local (\st -> st{envCurSlideId = ident}) (blocksToSlide bs))
819 local (\st -> st{envCurSlideId = ident}) (blocksToSlide bs))
813 (zip blksLst bodySlideIds)
820 (zip blksLst bodySlideIds)
814− let endNoteStartNum = bodyStartNum + length bodyslides
815 endNotesSlideBlocks <- makeEndNotesSlideBlocks
821 endNotesSlideBlocks <- makeEndNotesSlideBlocks
816 -- now we come back and make the real toc...
822 -- now we come back and make the real toc...
817 tocSlides <- if writerTableOfContents opts
823 tocSlides <- if writerTableOfContents opts
@@ -821,13 +827,13 @@ blocksToPresentation blks = do
821 -- ... and the notes slide. We test to see if the blocks are empty,
827 -- ... and the notes slide. We test to see if the blocks are empty,
822 -- because we don't want to make an empty slide.
828 -- because we don't want to make an empty slide.
823 endNotesSlides <- if null endNotesSlideBlocks
829 endNotesSlides <- if null endNotesSlideBlocks
824− then return []
830+ then return []
825− else do endNotesSlide <- local
831+ else do endNotesSlide <- local
826− (\env -> env { envCurSlideId = SlideId $ show endNoteStartNum
832+ (\env -> env { envCurSlideId = endNotesSlideId
827− , envInNoteSlide = True
833+ , envInNoteSlide = True
829− (blocksToSlide $ endNotesSlideBlocks)
835+ (blocksToSlide $ endNotesSlideBlocks)
830− return [endNotesSlide]
836+ return [endNotesSlide]
832 let slides = metadataslides ++ tocSlides ++ bodyslides ++ endNotesSlides
838 let slides = metadataslides ++ tocSlides ++ bodyslides ++ endNotesSlides
833 slides' <- mapM (applyToSlide replaceAnchor) slides
839 slides' <- mapM (applyToSlide replaceAnchor) slides