aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2018-01-03 20:52:48 -0500
committerJesse Rosenthal <jrosenthal@jhu.edu>2018-01-03 20:52:48 -0500
commit41dc65b37f19fefb5036d40d631a9d29561dc422 (patch)
tree111f0efefc6d30ba6498433d2025167ce7f1bf79 /src
parent101aece6cc03eb8dc434f2ff23bd4d66198fb592 (diff)
downloadpandoc-41dc65b37f19fefb5036d40d631a9d29561dc422.tar.gz
Powerpoint writer: Split blocks correctly for linked images
We treat links with an image as the first inline as an image with a link picProp -- so we have to split on it the same as if it were an image.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Powerpoint.hs25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Writers/Powerpoint.hs b/src/Text/Pandoc/Writers/Powerpoint.hs
index cac3a0af9..073cd72a1 100644
--- a/src/Text/Pandoc/Writers/Powerpoint.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint.hs
@@ -513,6 +513,11 @@ blockToShape blk = TextBox <$> blockToParagraphs blk
blocksToShapes :: PandocMonad m => [Block] -> P m [Shape]
blocksToShapes blks = combineShapes <$> mapM blockToShape blks
+isImage :: Inline -> Bool
+isImage (Image _ _ _) = True
+isImage (Link _ ((Image _ _ _) : _) _) = True
+isImage _ = False
+
splitBlocks' :: Monad m => [Block] -> [[Block]] -> [Block] -> P m [[Block]]
splitBlocks' cur acc [] = return $ acc ++ (if null cur then [] else [cur])
splitBlocks' cur acc (HorizontalRule : blks) =
@@ -523,26 +528,26 @@ splitBlocks' cur acc (h@(Header n _ _) : blks) = do
LT -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[h]]) blks
EQ -> splitBlocks' [h] (acc ++ (if null cur then [] else [cur])) blks
GT -> splitBlocks' (cur ++ [h]) acc blks
-splitBlocks' cur acc ((Para (img@(Image _ _ _):ils)) : blks) = do
+splitBlocks' cur acc ((Para (il:ils)) : blks) | isImage il = do
slideLevel <- asks envSlideLevel
case cur of
(Header n _ _) : [] | n == slideLevel ->
splitBlocks' []
- (acc ++ [cur ++ [Para [img]]])
+ (acc ++ [cur ++ [Para [il]]])
(if null ils then blks else (Para ils) : blks)
- _ -> splitBlocks' []
- (acc ++ (if null cur then [] else [cur]) ++ [[Para [img]]])
- (if null ils then blks else (Para ils) : blks)
-splitBlocks' cur acc ((Plain (img@(Image _ _ _):ils)) : blks) = do
+ _ -> splitBlocks' []
+ (acc ++ (if null cur then [] else [cur]) ++ [[Para [il]]])
+ (if null ils then blks else (Para ils) : blks)
+splitBlocks' cur acc ((Plain (il:ils)) : blks) | isImage il = do
slideLevel <- asks envSlideLevel
case cur of
(Header n _ _) : [] | n == slideLevel ->
splitBlocks' []
- (acc ++ [cur ++ [Para [img]]])
+ (acc ++ [cur ++ [Plain [il]]])
(if null ils then blks else (Plain ils) : blks)
- _ -> splitBlocks' []
- (acc ++ (if null cur then [] else [cur]) ++ [[Para [img]]])
- (if null ils then blks else (Plain ils) : blks)
+ _ -> splitBlocks' []
+ (acc ++ (if null cur then [] else [cur]) ++ [[Plain [il]]])
+ (if null ils then blks else (Plain ils) : blks)
splitBlocks' cur acc (tbl@(Table _ _ _ _ _) : blks) = do
slideLevel <- asks envSlideLevel
case cur of