git.iko.soy/typeable/pandoc
on master help sign in
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.

commit41dc65b37f19fefb5036d40d631a9d29561dc422 authorJesse Rosenthal <jrosenthal@jhu.edu> dateWed 3 Jan 2018, 20:52 (9 years ago) parent101aece
1 file changed+15−10
src/Text/Pandoc/Writers/Powerpoint.hs+15−10
src/Text/Pandoc/Writers/Powerpoint.hs+15−10
@@ -513,6 +513,11 @@ blockToShape blk = TextBox <$> blockToParagraphs blk
513513blocksToShapes :: PandocMonad m => [Block] -> P m [Shape]
514514blocksToShapes blks = combineShapes <$> mapM blockToShape blks
515515
516+isImage :: Inline -> Bool
517+isImage (Image _ _ _) = True
518+isImage (Link _ ((Image _ _ _) : _) _) = True
519+isImage _ = False
520+
516521splitBlocks' :: Monad m => [Block] -> [[Block]] -> [Block] -> P m [[Block]]
517522splitBlocks' cur acc [] = return $ acc ++ (if null cur then [] else [cur])
518523splitBlocks' cur acc (HorizontalRule : blks) =
@@ -523,26 +528,26 @@ splitBlocks' cur acc (h@(Header n _ _) : blks) = do
523528 LT -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[h]]) blks
524529 EQ -> splitBlocks' [h] (acc ++ (if null cur then [] else [cur])) blks
525530 GT -> splitBlocks' (cur ++ [h]) acc blks
526−splitBlocks' cur acc ((Para (img@(Image _ _ _):ils)) : blks) = do
531+splitBlocks' cur acc ((Para (il:ils)) : blks) | isImage il = do
527532 slideLevel <- asks envSlideLevel
528533 case cur of
529534 (Header n _ _) : [] | n == slideLevel ->
530535 splitBlocks' []
531− (acc ++ [cur ++ [Para [img]]])
536+ (acc ++ [cur ++ [Para [il]]])
532537 (if null ils then blks else (Para ils) : blks)
533− _ -> splitBlocks' []
534− (acc ++ (if null cur then [] else [cur]) ++ [[Para [img]]])
535− (if null ils then blks else (Para ils) : blks)
536−splitBlocks' cur acc ((Plain (img@(Image _ _ _):ils)) : blks) = do
538+ _ -> splitBlocks' []
539+ (acc ++ (if null cur then [] else [cur]) ++ [[Para [il]]])
540+ (if null ils then blks else (Para ils) : blks)
541+splitBlocks' cur acc ((Plain (il:ils)) : blks) | isImage il = do
537542 slideLevel <- asks envSlideLevel
538543 case cur of
539544 (Header n _ _) : [] | n == slideLevel ->
540545 splitBlocks' []
541− (acc ++ [cur ++ [Para [img]]])
546+ (acc ++ [cur ++ [Plain [il]]])
542547 (if null ils then blks else (Plain ils) : blks)
543− _ -> splitBlocks' []
544− (acc ++ (if null cur then [] else [cur]) ++ [[Para [img]]])
545− (if null ils then blks else (Plain ils) : blks)
548+ _ -> splitBlocks' []
549+ (acc ++ (if null cur then [] else [cur]) ++ [[Plain [il]]])
550+ (if null ils then blks else (Plain ils) : blks)
546551splitBlocks' cur acc (tbl@(Table _ _ _ _ _) : blks) = do
547552 slideLevel <- asks envSlideLevel
548553 case cur of