Skip to content

Commit

Permalink
Markdown writer: be sure implicit figures work in list contexts.
Browse files Browse the repository at this point in the history
Previously they would sometimes not work: e.g., when they
occured in final paragraphs in lists that were originally
parsed as Plain and converted later using PlainToPara.

Closes #5368.
  • Loading branch information
jgm committed Mar 15, 2019
1 parent 16bf907 commit 8632526
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/Text/Pandoc/Readers/Markdown.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,18 @@ normalDefinitionList = do
para :: PandocMonad m => MarkdownParser m (F Blocks)
para = try $ do
exts <- getOption readerExtensions
result <- trimInlinesF <$> inlines1
let implicitFigures x
| extensionEnabled Ext_implicit_figures exts = do
x' <- x
case B.toList x' of
[Image attr alt (src,tit)]
| not (null alt) ->
-- the fig: at beginning of title indicates a figure
return $ B.singleton
$ Image attr alt (src,'f':'i':'g':':':tit)
_ -> return x'
| otherwise = x
result <- implicitFigures . trimInlinesF <$> inlines1
option (B.plain <$> result)
$ try $ do
newline
Expand All @@ -1062,16 +1073,7 @@ para = try $ do
if divLevel > 0
then lookAhead divFenceEnd
else mzero
return $ do
result' <- result
case B.toList result' of
[Image attr alt (src,tit)]
| not (null alt) &&
Ext_implicit_figures `extensionEnabled` exts ->
-- the fig: at beginning of title indicates a figure
return $ B.para $ B.singleton
$ Image attr alt (src,'f':'i':'g':':':tit)
_ -> return $ B.para result'
return $ B.para <$> result

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

0 comments on commit 8632526

Please sign in to comment.