git.iko.soy/typeable/pandoc
on master help sign in
Pass through aria- attributes to HTML5.

Also document addition of data- prefix to unknown attributes. Closes #5646.

commit6d30d3e0b3b4a7005018179ff1098dd16eeb2652 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 12 Jul 2019, 17:03 (7 years ago) parentc497d79
3 files changed+14−4
MANUAL.txt+5−4 src/Text/Pandoc/Writers/HTML.hs+1 test/command/5646.md+8
MANUAL.txt+5−4
@@ -3967,10 +3967,11 @@ Attributes can be set on links and images:
39673967(This syntax is compatible with [PHP Markdown Extra] when only `#id`
39683968and `.class` are used.)
39693969
3970−For HTML and EPUB, all attributes except `width` and `height` (but
3971−including `srcset` and `sizes`) are passed through as is. The other
3972−writers ignore attributes that are not supported by their output
3973−format.
3970+For HTML and EPUB, all known HTML5 attributes except `width` and
3971+`height` (but including `srcset` and `sizes`) are passed through
3972+as is. Unknown attributes are passed through as custom
3973+attributes, with `data-` prepended. The other writers ignore
3974+attributes that are not specifically supported by their output format.
39743975
39753976The `width` and `height` attributes on images are treated specially. When
39763977used without a unit, the unit is assumed to be pixels. However, any of
src/Text/Pandoc/Writers/HTML.hs+1
@@ -621,6 +621,7 @@ toAttrs kvs = do
621621 if x `Set.member` (html5Attributes <> rdfaAttributes)
622622 || ':' `elem` x -- e.g. epub: namespace
623623 || "data-" `isPrefixOf` x
624+ || "aria-" `isPrefixOf` x
624625 then Just $ customAttribute (fromString x) (toValue y)
625626 else Just $ customAttribute (fromString ("data-" ++ x))
626627 (toValue y)
test/command/5646.mdnew file+8
@@ -0,0 +1,8 @@
1+```
2+% pandoc -t html5 -f markdown
3+![test](foo){aria-describedby="barbaz"}
4+^D
5+<figure>
6+<img src="foo" aria-describedby="barbaz" alt="" /><figcaption>test</figcaption>
7+</figure>
8+```