@@ -638,25 +638,26 @@ forceFontSize px x = do
638638 rpr <- asks envRunProps
639639 local (\r -> r {envRunProps = rpr{rPropForceSize = Just px}}) x
640640
641−-- Right now, there's no logic for making more than one slide, but I
642−-- want to leave the option open to make multiple slides if we figure
643−-- out how to guess at how much space the text of the notes will take
644−-- up (or if we allow a way for it to be manually controlled). Plus a
645−-- list will make it easier to put together in the final
646−-- `blocksToPresentation` function (since we can just add an empty
647−-- list without checking the state).
648−makeNotesSlides :: PandocMonad m => P m [Slide]
649−makeNotesSlides = local (\env -> env{envInNoteSlide=True}) $ do
641+-- We leave these as blocks because we will want to include them in
642+-- the TOC.
643+makeNotesSlideBlocks :: PandocMonad m => P m [Block]
644+makeNotesSlideBlocks = do
650645 noteIds <- gets stNoteIds
651646 slideLevel <- asks envSlideLevel
647+ meta <- asks envMetadata
648+ -- Get identifiers so we can give the notes section a unique ident.
649+ anchorSet <- M.keysSet <$> gets stAnchorMap
652650 if M.null noteIds
653651 then return []
654− else do let hdr = Header slideLevel nullAttr [Str "Notes"]
652+ else do let title = case lookupMeta "notes-title" meta of
653+ Just val -> metaValueToInlines val
654+ Nothing -> [Str "Notes"]
655+ ident = Shared.uniqueIdent title anchorSet
656+ hdr = Header slideLevel (ident, [], []) title
655657 blks <- return $
656658 concatMap (\(n, bs) -> makeNoteEntry n bs) $
657659 M.toList noteIds
658− sld <- blocksToSlide $ hdr : blks
659− return [sld]
660+ return $ hdr : blks
660661
661662getMetaSlide :: PandocMonad m => P m (Maybe Slide)
662663getMetaSlide = do
@@ -711,21 +712,43 @@ blocksToPresentation blks = do
711712 let metadataStartNum = 1
712713 metadataslides <- maybeToList <$> getMetaSlide
713714 let tocStartNum = metadataStartNum + length metadataslides
714− tocSlides <- if writerTableOfContents opts
715− then do toc <- makeTOCSlide blks
716− return [toc]
717− else return []
718− let bodyStartNum = tocStartNum + length tocSlides
715+ -- As far as I can tell, if we want to have a variable-length toc in
716+ -- the future, we'll have to make it twice. Once to get the length,
717+ -- and a second time to include the notes slide. We can't make the
718+ -- notes slide before the body slides because we need to know if
719+ -- there are notes, and we can't make either before the toc slide,
720+ -- because we need to know its length to get slide numbers right.
721+ --
722+ -- For now, though, since the TOC slide is only length 1, if it
723+ -- exists, we'll just get the length, and then come back to make the
724+ -- slide later
725+ let tocSlidesLength = if writerTableOfContents opts then 1 else 0
726+ let bodyStartNum = tocStartNum + tocSlidesLength
719727 blksLst <- splitBlocks blks
720728 bodyslides <- mapM
721729 (\(bs, n) -> local (\st -> st{envCurSlideId = n}) (blocksToSlide bs))
722730 (zip blksLst [bodyStartNum..])
723731 let noteStartNum = bodyStartNum + length bodyslides
724− noteSlides <- local (\st -> st {envCurSlideId = noteStartNum}) makeNotesSlides
732+ notesSlideBlocks <- makeNotesSlideBlocks
733+ -- now we come back and make the real toc...
734+ tocSlides <- if writerTableOfContents opts
735+ then do toc <- makeTOCSlide $ blks ++ notesSlideBlocks
736+ return [toc]
737+ else return []
738+ -- ... and the notes slide. We test to see if the blocks are empty,
739+ -- because we don't want to make an empty slide.
740+ notesSlides <- if null notesSlideBlocks
741+ then return []
742+ else do notesSlide <- local
743+ (\env -> env { envCurSlideId = noteStartNum
744+ , envInNoteSlide = True
745+ })
746+ (blocksToSlide $ notesSlideBlocks)
747+ return [notesSlide]
725748 presSize <- asks envPresentationSize
726749 return $
727750 Presentation presSize $
728− metadataslides ++ tocSlides ++ bodyslides ++ noteSlides
751+ metadataslides ++ tocSlides ++ bodyslides ++ notesSlides
729752
730753--------------------------------------------------------------------
731754