@@ -113,7 +113,7 @@ data WriterState = WriterState { stNoteIds :: M.Map Int [Block]
113113 , stAnchorMap :: M.Map String SlideId
114114 , stSlideIdSet :: S.Set SlideId
115115 , stLog :: [LogMessage]
116− , stSpeakerNotesMap :: M.Map SlideId [[Paragraph]]
116+ , stSpeakerNotes :: SpeakerNotes
117117 } deriving (Show, Eq)
118118
119119instance Default WriterState where
@@ -122,7 +122,7 @@ instance Default WriterState where
122122 -- we reserve this s
123123 , stSlideIdSet = reservedSlideIds
124124 , stLog = []
125− , stSpeakerNotesMap = mempty
125+ , stSpeakerNotes = mempty
126126 }
127127
128128metadataSlideId :: SlideId
@@ -196,7 +196,7 @@ newtype SlideId = SlideId String
196196-- designed mainly for one textbox, so we'll just put in the contents
197197-- of that textbox, to avoid other shapes that won't work as well.
198198newtype SpeakerNotes = SpeakerNotes {fromSpeakerNotes :: [Paragraph]}
199− deriving (Show, Eq, Monoid)
199+ deriving (Show, Eq, Monoid, Semigroup)
200200
201201data Layout = MetadataSlide { metadataSlideTitle :: [ParaElem]
202202 , metadataSlideSubtitle :: [ParaElem]
@@ -565,13 +565,8 @@ isNotesDiv _ = False
565565handleNotes :: Block -> Pres ()
566566handleNotes (Div (_, ["notes"], _) blks) =
567567 local (\env -> env{envInSpeakerNotes=True}) $ do
568− sldId <- asks envCurSlideId
569− spkNotesMap <- gets stSpeakerNotesMap
570− paras <- concatMapM blockToParagraphs blks
571− let spkNotesMap' = case M.lookup sldId spkNotesMap of
572− Just lst -> M.insert sldId (paras : lst) spkNotesMap
573− Nothing -> M.insert sldId [paras] spkNotesMap
574− modify $ \st -> st{stSpeakerNotesMap = spkNotesMap'}
568+ spNotes <- SpeakerNotes <$> concatMapM blockToParagraphs blks
569+ modify $ \st -> st{stSpeakerNotes = (stSpeakerNotes st) <> spNotes}
575570handleNotes _ = return ()
576571
577572handleAndFilterNotes :: [Block] -> Pres [Block]
@@ -632,13 +627,6 @@ splitBlocks' cur acc (blk : blks) = splitBlocks' (cur ++ [blk]) acc blks
632627splitBlocks :: [Block] -> Pres [[Block]]
633628splitBlocks = splitBlocks' [] []
634629
635−getSpeakerNotes :: Pres SpeakerNotes
636−getSpeakerNotes = do
637− sldId <- asks envCurSlideId
638− spkNtsMap <- gets stSpeakerNotesMap
639− let paras = fromMaybe [] (M.lookup sldId spkNtsMap)
640− return $ SpeakerNotes $ concat $ reverse paras
641−
642630blocksToSlide' :: Int -> [Block] -> Pres Slide
643631blocksToSlide' lvl (Header n (ident, _, _) ils : blks)
644632 | n < lvl = do
@@ -710,9 +698,10 @@ blocksToSlide' _ [] = do
710698blocksToSlide :: [Block] -> Pres Slide
711699blocksToSlide blks = do
712700 slideLevel <- asks envSlideLevel
701+ modify $ \st -> st{stSpeakerNotes = mempty}
713702 blks' <- walkM handleAndFilterNotes blks
714703 sld <- blocksToSlide' slideLevel blks'
715− spkNotes <- getSpeakerNotes
704+ spkNotes <- gets stSpeakerNotes
716705 return $ sld{slideSpeakerNotes = spkNotes}
717706
718707makeNoteEntry :: Int -> [Block] -> [Block]