diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2024-02-29 12:08:02 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2024-02-29 12:08:02 -0800 |
| commit | 85b3ac3ee1a470c5c48ef8288865f115594090be (patch) | |
| tree | 73a2ce83e12c05e3b7cb63f363e2a9ea1e92cb65 /src | |
| parent | 6c88c39c6dbcf8ac4033bf377c71a8713eaba900 (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.hs | 8 |
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 |
