diff options
| author | John MacFarlane <[email protected]> | 2025-04-05 11:31:35 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-04-05 11:32:29 -0700 |
| commit | 0d2114ee4e3974583ee84e8a4e992562d6502f66 (patch) | |
| tree | 4c70996d39bb8b31ded1284c467217b0ae47c32a /src/Text | |
| parent | 0cf41697c583539d62b1baeaa9cac18c8931866c (diff) | |
Markdown writer: improve use of implicit figures when possible.
Closes #10758.
When the alt differs from the caption, but only as regards
formatting, we still use an implicit figure.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index c2e7e7f5e..a25e2761a 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -709,16 +709,20 @@ blockToMarkdown' opts (DefinitionList items) = do return $ mconcat contents <> blankline blockToMarkdown' opts (Figure figattr capt body) = do let combinedAttr imgattr = case imgattr of - ("", cls, kv) | (figid, [], []) <- figattr -> Just (figid, cls, kv) + ("", cls, kv) + | (figid, [], []) <- figattr -> Just (figid, cls, kv) + | otherwise -> Just ("", cls, kv) _ -> Nothing let combinedAlt alt = case capt of Caption Nothing [] -> if null alt then Just [Str "image"] else Just alt Caption Nothing [Plain captInlines] - | captInlines == alt || null alt -> Just captInlines + | null alt || stringify captInlines == stringify alt + -> Just captInlines Caption Nothing [Para captInlines] - | captInlines == alt || null alt -> Just captInlines + | null alt || stringify captInlines == stringify alt + -> Just captInlines _ -> Nothing case body of [Plain [Image imgAttr alt (src, ttl)]] |
