mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-27 18:05:48 +00:00
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.
This commit is contained in:
@@ -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)]]
|
||||
|
||||
Reference in New Issue
Block a user