aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2018-03-21 09:02:16 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2018-03-21 10:07:07 -0400
commitcb1ee07c9819bafa48a62c518e94cc95281697c1 (patch)
tree5ef5b87bd6df668a6dfc9dbaaa16138795fbd5cc /src/Text
parent532cfcc59ff7929da29e6d19fd9a61c4198c1750 (diff)
downloadpandoc-cb1ee07c9819bafa48a62c518e94cc95281697c1.tar.gz
Powerpoint writer: Keep notes with related blocks
Some blocks automatically split slides (imgs, tables, `column` divs). We assume that any speaker notes immediately following these are connected to these elements, and keep them with the related blocks, splitting after them.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Powerpoint/Presentation.hs25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs
index 4f8a0908b..550071600 100644
--- a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs
@@ -575,6 +575,10 @@ isImage Image{} = True
isImage (Link _ (Image{} : _) _) = True
isImage _ = False
+isNotesDiv :: Block -> Bool
+isNotesDiv (Div (_, ["notes"], _) _) = True
+isNotesDiv _ = False
+
splitBlocks' :: [Block] -> [[Block]] -> [Block] -> Pres [[Block]]
splitBlocks' cur acc [] = return $ acc ++ (if null cur then [] else [cur])
splitBlocks' cur acc (HorizontalRule : blks) =
@@ -590,26 +594,31 @@ splitBlocks' cur acc (h@(Header n _ _) : blks) = do
splitBlocks' cur acc (Plain ils : blks) = splitBlocks' cur acc (Para ils : blks)
splitBlocks' cur acc (Para (il:ils) : blks) | isImage il = do
slideLevel <- asks envSlideLevel
+ let (nts, blks') = if null ils
+ then span isNotesDiv blks
+ else ([], blks)
case cur of
[Header n _ _] | n == slideLevel ->
splitBlocks' []
- (acc ++ [cur ++ [Para [il]]])
- (if null ils then blks else Para ils : blks)
+ (acc ++ [cur ++ [Para [il]] ++ nts])
+ (if null ils then blks' else Para ils : blks')
_ -> splitBlocks' []
- (acc ++ (if null cur then [] else [cur]) ++ [[Para [il]]])
- (if null ils then blks else Para ils : blks)
+ (acc ++ (if null cur then [] else [cur]) ++ [[Para [il]] ++ nts])
+ (if null ils then blks' else Para ils : blks')
splitBlocks' cur acc (tbl@Table{} : blks) = do
slideLevel <- asks envSlideLevel
+ let (nts, blks') = span isNotesDiv blks
case cur of
[Header n _ _] | n == slideLevel ->
- splitBlocks' [] (acc ++ [cur ++ [tbl]]) blks
- _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[tbl]]) blks
+ splitBlocks' [] (acc ++ [cur ++ [tbl] ++ nts]) blks'
+ _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[tbl] ++ nts]) blks'
splitBlocks' cur acc (d@(Div (_, classes, _) _): blks) | "columns" `elem` classes = do
slideLevel <- asks envSlideLevel
+ let (nts, blks') = span isNotesDiv blks
case cur of
[Header n _ _] | n == slideLevel ->
- splitBlocks' [] (acc ++ [cur ++ [d]]) blks
- _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[d]]) blks
+ splitBlocks' [] (acc ++ [cur ++ [d] ++ nts]) blks'
+ _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[d] ++ nts]) blks'
splitBlocks' cur acc (blk : blks) = splitBlocks' (cur ++ [blk]) acc blks
splitBlocks :: [Block] -> Pres [[Block]]