diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-03-14 21:43:25 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-03-14 21:43:25 -0700 |
commit | 8632526fc20c59df635d9cad77e1453155f8680d (patch) | |
tree | 04ec16a7b735e24554bb66d3d934e4e36098c28b /src/Text | |
parent | 16bf90725284ae86298229c4afb6e3ec951571fa (diff) | |
download | pandoc-8632526fc20c59df635d9cad77e1453155f8680d.tar.gz |
Markdown writer: be sure implicit figures work in list contexts.
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.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 2ae07c6a1..442c34511 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -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 @@ -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 |