@@ -618,7 +618,8 @@ propertiesDrawer = try $ do
618-- Figures
618-- Figures
621−-- | Figures (Image on a line by itself, preceded by name and/or caption)
621+-- | Figures or an image paragraph (i.e. an image on a line by itself). Only
622+-- images with a caption attribute are interpreted as figures.
622figure :: OrgParser (F Blocks)
623figure :: OrgParser (F Blocks)
623figure = try $ do
624figure = try $ do
624 figAttrs <- blockAttributes
625 figAttrs <- blockAttributes
@@ -626,23 +627,24 @@ figure = try $ do
626 case cleanLinkString src of
627 case cleanLinkString src of
627 Nothing -> mzero
628 Nothing -> mzero
628 Just imgSrc -> do
629 Just imgSrc -> do
629− guard (not . isNothing . blockAttrCaption $ figAttrs)
630 guard (isImageFilename imgSrc)
630 guard (isImageFilename imgSrc)
631+ let isFigure = not . isNothing $ blockAttrCaption figAttrs
631− return $ figureBlock figAttrs imgSrc
632+ return $ imageBlock isFigure figAttrs imgSrc
633 selfTarget :: OrgParser String
634 selfTarget :: OrgParser String
634 selfTarget = try $ char '[' *> linkTarget <* char ']'
635 selfTarget = try $ char '[' *> linkTarget <* char ']'
636− figureBlock :: BlockAttributes -> String -> (F Blocks)
637+ imageBlock :: Bool -> BlockAttributes -> String -> F Blocks
637− figureBlock figAttrs imgSrc =
638+ imageBlock isFigure figAttrs imgSrc =
639 figName = fromMaybe mempty $ blockAttrName figAttrs
640 figName = fromMaybe mempty $ blockAttrName figAttrs
640 figLabel = fromMaybe mempty $ blockAttrLabel figAttrs
641 figLabel = fromMaybe mempty $ blockAttrLabel figAttrs
641 figCaption = fromMaybe mempty $ blockAttrCaption figAttrs
642 figCaption = fromMaybe mempty $ blockAttrCaption figAttrs
642 figKeyVals = blockAttrKeyValues figAttrs
643 figKeyVals = blockAttrKeyValues figAttrs
643 attr = (figLabel, mempty, figKeyVals)
644 attr = (figLabel, mempty, figKeyVals)
645+ figTitle = (if isFigure then withFigPrefix else id) figName
645− B.para . B.imageWith attr imgSrc (withFigPrefix figName) <$> figCaption
647+ B.para . B.imageWith attr imgSrc figTitle <$> figCaption
647 withFigPrefix :: String -> String
649 withFigPrefix :: String -> String
648 withFigPrefix cs =
650 withFigPrefix cs =