aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-09-14 17:42:31 +0200
committerJohn MacFarlane <[email protected]>2025-09-15 10:50:04 +0200
commit9c36d884d5713a43294fe0a1a7046d55d9ae57c3 (patch)
tree52b066ef2f142fa23e311ec239e8365c9f2ca32a /src
parente2f088f4e5ea1543757b064b3871b483109bda42 (diff)
RST reader: parse `:alt:` on figure.
Also give a better default if `alt` is not specified, using the stringified caption rather than the filename. Partially addresses #11140. Add failing test case for Markdown writer issue in #11140.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 989aab3ac..7158b804e 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -855,8 +855,9 @@ directive' = do
let figcls = concatMap (T.words . snd) figclasskv
let figattr = ("", figcls ++ aligncls, [])
let capt = B.caption Nothing (B.plain caption <> legend)
+ let alt = maybe caption (B.text . trim) (lookup "alt" fields)
return $ B.figureWith figattr capt $
- B.plain (B.imageWith (imgident, imgcls, imgkvs) src "" (B.text src))
+ B.plain (B.imageWith (imgident, imgcls, imgkvs) src "" alt)
"image" -> do
let src = escapeURI $ trim top
let alt = B.str $ maybe "image" trim $ lookup "alt" fields