@@ -58,6 +58,7 @@ import Control.Monad.State
5858import Data.List (intercalate)
5959import Data.Default
6060import Text.Pandoc.Definition
61+import Text.Pandoc.ImageSize
6162import Text.Pandoc.Slides (getSlideLevel)
6263import Text.Pandoc.Options
6364import Text.Pandoc.Logging
@@ -138,7 +139,7 @@ data Slide = MetadataSlide { metadataSlideTitle :: [ParaElem]
138139 }
139140 deriving (Show, Eq)
140141
141−data Shape = Pic PicProps FilePath Text.Pandoc.Definition.Attr [ParaElem]
142+data Shape = Pic PicProps FilePath [ParaElem]
142143 | GraphicFrame [Graphic] [ParaElem]
143144 | TextBox [Paragraph]
144145 deriving (Show, Eq)
@@ -230,10 +231,14 @@ instance Default RunProps where
230231 }
231232
232233data PicProps = PicProps { picPropLink :: Maybe LinkTarget
234+ , picWidth :: Maybe Dimension
235+ , picHeight :: Maybe Dimension
233236 } deriving (Show, Eq)
234237
235238instance Default PicProps where
236239 def = PicProps { picPropLink = Nothing
240+ , picWidth = Nothing
241+ , picHeight = Nothing
237242 }
238243
239244--------------------------------------------------
@@ -407,17 +412,28 @@ rowToParagraphs algns tblCells = do
407412 let pairs = zip (algns ++ repeat AlignDefault) tblCells
408413 mapM (\(a, tc) -> cellToParagraphs a tc) pairs
409414
415+withAttr :: Attr -> Shape -> Shape
416+withAttr attr (Pic picPr url caption) =
417+ let picPr' = picPr { picWidth = dimension Width attr
418+ , picHeight = dimension Height attr
419+ }
420+ in
421+ Pic picPr' url caption
422+withAttr _ sp = sp
423+
410424blockToShape :: Block -> Pres Shape
411425blockToShape (Plain (il:_)) | Image attr ils (url, _) <- il =
412− Pic def url attr <$> (inlinesToParElems ils)
426+ (withAttr attr . Pic def url) <$> (inlinesToParElems ils)
413427blockToShape (Para (il:_)) | Image attr ils (url, _) <- il =
414− Pic def url attr <$> (inlinesToParElems ils)
428+ (withAttr attr . Pic def url) <$> (inlinesToParElems ils)
415429blockToShape (Plain (il:_)) | Link _ (il':_) target <- il
416430 , Image attr ils (url, _) <- il' =
417− Pic def{picPropLink = Just $ ExternalTarget target} url attr <$> (inlinesToParElems ils)
431+ (withAttr attr . Pic def {picPropLink = Just $ ExternalTarget target} url) <$>
432+ (inlinesToParElems ils)
418433blockToShape (Para (il:_)) | Link _ (il':_) target <- il
419434 , Image attr ils (url, _) <- il' =
420− Pic def{picPropLink = Just $ ExternalTarget target} url attr <$> (inlinesToParElems ils)
435+ (withAttr attr . Pic def{picPropLink = Just $ ExternalTarget target} url) <$>
436+ (inlinesToParElems ils)
421437blockToShape (Table caption algn _ hdrCells rows) = do
422438 caption' <- inlinesToParElems caption
423439 hdrCells' <- rowToParagraphs algn hdrCells
@@ -438,7 +454,7 @@ blockToShape blk = do paras <- blockToParagraphs blk
438454combineShapes :: [Shape] -> [Shape]
439455combineShapes [] = []
440456combineShapes (s : []) = [s]
441−combineShapes (pic@(Pic _ _ _ _) : ss) = pic : combineShapes ss
457+combineShapes (pic@(Pic _ _ _) : ss) = pic : combineShapes ss
442458combineShapes ((TextBox []) : ss) = combineShapes ss
443459combineShapes (s : TextBox [] : ss) = combineShapes (s : ss)
444460combineShapes ((TextBox (p:ps)) : (TextBox (p':ps')) : ss) =
@@ -650,9 +666,9 @@ applyToParagraph f para = do
650666 return $ para {paraElems = paraElems'}
651667
652668applyToShape :: Monad m => (ParaElem -> m ParaElem) -> Shape -> m Shape
653−applyToShape f (Pic pPr fp attr pes) = do
669+applyToShape f (Pic pPr fp pes) = do
654670 pes' <- mapM f pes
655− return $ Pic pPr fp attr pes'
671+ return $ Pic pPr fp pes'
656672applyToShape f (GraphicFrame gfx pes) = do
657673 pes' <- mapM f pes
658674 return $ GraphicFrame gfx pes'