summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2024-02-29 12:08:02 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2024-02-29 12:08:02 -0800
commit85b3ac3ee1a470c5c48ef8288865f115594090be (patch)
tree73a2ce83e12c05e3b7cb63f363e2a9ea1e92cb65 /src
parent6c88c39c6dbcf8ac4033bf377c71a8713eaba900 (diff)
SelfContained: Add aria-label to svg elements.
Screen readers don't seem to pay attention to an alt attribute on svg. But they do read the aria-label. So if there's an alt attribute, we copy its contents to aria-label, unless there is already an aria-label. This will make pandoc's output with `--embed-resources` more accessible. Closes #9525.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/SelfContained.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs
index fdec874ff..e59971231 100644
--- a/src/Text/Pandoc/SelfContained.hs
+++ b/src/Text/Pandoc/SelfContained.hs
@@ -146,7 +146,13 @@ convertTags (t@(TagOpen tagname as):ts)
| any (isSourceAttribute tagname) as
= do
as' <- mapM processAttribute as
- let attrs = rights as'
+ let rawattrs = rights as'
+ let attrs = case lookup "alt" rawattrs of
+ Nothing -> rawattrs
+ Just alt -> -- see #9525
+ case lookup "aria-label" rawattrs of
+ Nothing -> ("aria-label", alt) : rawattrs
+ Just _ -> rawattrs
let svgContents = lefts as'
rest <- convertTags ts
case svgContents of