git.iko.soy/typeable/pandoc
on master help sign in
Pass through aria- attributes to HTML5.
6d30d3eJohn MacFarlane
MANUAL.txt+5−4
@@ -3967,10 +3967,11 @@ Attributes can be set on links and images:
3967(This syntax is compatible with [PHP Markdown Extra] when only `#id`
3967(This syntax is compatible with [PHP Markdown Extra] when only `#id`
3968and `.class` are used.)
3968and `.class` are used.)
3969
3969
3970−For HTML and EPUB, all attributes except `width` and `height` (but
3970+For HTML and EPUB, all known HTML5 attributes except `width` and
3971−including `srcset` and `sizes`) are passed through as is. The other
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
3972−writers ignore attributes that are not supported by their output
3974+attributes that are not specifically supported by their output format.
3973−format.
3974
3975
3975The `width` and `height` attributes on images are treated specially. When
3976The `width` and `height` attributes on images are treated specially. When
3976used without a unit, the unit is assumed to be pixels. However, any of
3977used 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
621 if x `Set.member` (html5Attributes <> rdfaAttributes)
621 if x `Set.member` (html5Attributes <> rdfaAttributes)
622 || ':' `elem` x -- e.g. epub: namespace
622 || ':' `elem` x -- e.g. epub: namespace
623 || "data-" `isPrefixOf` x
623 || "data-" `isPrefixOf` x
624+ || "aria-" `isPrefixOf` x
624 then Just $ customAttribute (fromString x) (toValue y)
625 then Just $ customAttribute (fromString x) (toValue y)
625 else Just $ customAttribute (fromString ("data-" ++ x))
626 else Just $ customAttribute (fromString ("data-" ++ x))
626 (toValue y)
627 (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+```