aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2017-12-21 12:11:58 -0500
committerJesse Rosenthal <jrosenthal@jhu.edu>2017-12-21 12:11:58 -0500
commitc4f58684ee3a53367efe381db908e6d6664d90ce (patch)
treec1a7003415683e92adabb68b6458faa277f1a60e /src/Text
parentf76b4fc497706c4939c51138384ac1414b6f8b08 (diff)
downloadpandoc-c4f58684ee3a53367efe381db908e6d6664d90ce.tar.gz
PowerPoint writer: Implement notes
This currently prints all notes on a final slide. Note that at the moment, there is a danger of text overflowing the note slide, since there is no logic for adding further slides. A future commit will shrink the font size on these notes, but that won't take care of the problem altogether. (We might have to implement some sort of clumsy page-breaking logic here based on font size and text-box dimensions, though that seems like a can of worms.)
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Powerpoint.hs32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Powerpoint.hs b/src/Text/Pandoc/Writers/Powerpoint.hs
index 4a6f6a341..c13b32d49 100644
--- a/src/Text/Pandoc/Writers/Powerpoint.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint.hs
@@ -564,6 +564,32 @@ blocksToSlide blks = do
slideLevel <- asks envSlideLevel
blocksToSlide' slideLevel blks
+makeNoteEntry :: Int -> [Block] -> [Block]
+makeNoteEntry n blks =
+ let enum = Str (show n ++ ".")
+ in
+ case blks of
+ (Para ils : blks') -> (Para $ enum : Space : ils) : blks'
+ _ -> (Para [enum]) : blks
+
+-- Right now, there's no logic for making more than one slide, but I
+-- want to leave the option open to make multiple slides if we figure
+-- out how to guess at how much space the text of the notes will take
+-- up (or if we allow a way for it to be manually controlled). Plus a
+-- list will make it easier to put together in the final
+-- `blocksToPresentation` function (since we can just add an empty
+-- list without checking the state).
+makeNotesSlides :: PandocMonad m => P m [Slide]
+makeNotesSlides = do
+ noteIds <- gets stNoteIds
+ if M.null noteIds
+ then return []
+ else do let hdr = Header 2 nullAttr [Str "Notes"]
+ blks = concatMap (\(n, bs) -> makeNoteEntry n bs) $
+ M.toList noteIds
+ sld <- blocksToSlide $ hdr : blks
+ return [sld]
+
getMetaSlide :: PandocMonad m => P m (Maybe Slide)
getMetaSlide = do
meta <- asks envMetadata
@@ -589,11 +615,13 @@ blocksToPresentation :: PandocMonad m => [Block] -> P m Presentation
blocksToPresentation blks = do
blksLst <- splitBlocks blks
slides <- mapM blocksToSlide blksLst
+ noteSlides <- makeNotesSlides
+ let slides' = slides ++ noteSlides
metadataslide <- getMetaSlide
presSize <- asks envPresentationSize
return $ case metadataslide of
- Just metadataslide' -> Presentation presSize $ metadataslide' : slides
- Nothing -> Presentation presSize slides
+ Just metadataslide' -> Presentation presSize $ metadataslide' : slides'
+ Nothing -> Presentation presSize slides'
--------------------------------------------------------------------