diff options
| author | John MacFarlane <[email protected]> | 2025-04-04 10:16:23 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-04-04 10:16:23 -0700 |
| commit | 2155b5f9bc5a08fa1044f8a7ba75ce40af630fb7 (patch) | |
| tree | 2fc63d4e8bea4d9e7769d8713e19e8150ddf7ab9 /src/Text | |
| parent | 84946bf819a373527f03b5f4091ca0bbe695aaa0 (diff) | |
Markdown writer: render a figure with Para caption as implicit figure.
Also, when falling back to a Div with class `figure` for a figure
that can't be represented any other way, include a Div with class
`caption` containing the caption.
Closes #10755.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 60cd4b370..c2e7e7f5e 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -717,6 +717,8 @@ blockToMarkdown' opts (Figure figattr capt body) = do else Just alt Caption Nothing [Plain captInlines] | captInlines == alt || null alt -> Just captInlines + Caption Nothing [Para captInlines] + | captInlines == alt || null alt -> Just captInlines _ -> Nothing case body of [Plain [Image imgAttr alt (src, ttl)]] @@ -763,8 +765,11 @@ figureToMarkdown opts attr@(ident, classes, kvs) capt body writeHtml5String opts{ writerTemplate = Nothing } (Pandoc nullMeta [Figure attr capt body]) - | otherwise = let attr' = (ident, ["figure"] `union` classes, kvs) - in blockToMarkdown' opts (Div attr' body) + | otherwise = do + let attr' = (ident, ["figure"] `union` classes, kvs) + let Caption _mbshort caption = capt + let captionBs = [Div ("",["caption"],[]) caption | not (null caption)] + blockToMarkdown' opts (Div attr' (body <> captionBs)) itemEndsWithTightList :: [Block] -> Bool itemEndsWithTightList bs = |
