Skip to content

Commit ee56a90

Browse files
committed
Use simpleFigureWith in Markdown reader
1 parent 40281c1 commit ee56a90

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/Text/Pandoc/Readers/Markdown.hs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,19 +1013,18 @@ normalDefinitionList = do
10131013
para :: PandocMonad m => MarkdownParser m (F Blocks)
10141014
para = try $ do
10151015
exts <- getOption readerExtensions
1016-
let implicitFigures x
1017-
| extensionEnabled Ext_implicit_figures exts = do
1018-
x' <- x
1019-
case B.toList x' of
1020-
[Image attr alt (src,tit)]
1021-
| not (null alt) ->
1022-
-- the fig: at beginning of title indicates a figure
1023-
return $ B.singleton
1024-
$ Image attr alt (src, "fig:" <> tit)
1025-
_ -> return x'
1026-
| otherwise = x
1027-
result <- implicitFigures . trimInlinesF <$> inlines1
1028-
option (B.plain <$> result)
1016+
1017+
result <- trimInlinesF <$> inlines1
1018+
let figureOr constr inlns =
1019+
case B.toList inlns of
1020+
[Image attr figCaption (src, tit)]
1021+
| extensionEnabled Ext_implicit_figures exts
1022+
, not (null figCaption) -> do
1023+
B.simpleFigureWith attr (B.fromList figCaption) src tit
1024+
1025+
_ -> constr inlns
1026+
1027+
option (figureOr B.plain <$> result)
10291028
$ try $ do
10301029
newline
10311030
(mempty <$ blanklines)
@@ -1047,7 +1046,7 @@ para = try $ do
10471046
if divLevel > 0
10481047
then lookAhead divFenceEnd
10491048
else mzero
1050-
return $ B.para <$> result
1049+
return $ figureOr B.para <$> result
10511050

10521051
plain :: PandocMonad m => MarkdownParser m (F Blocks)
10531052
plain = fmap B.plain . trimInlinesF <$> inlines1

0 commit comments

Comments
 (0)