mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user