diff options
-rw-r--r-- | MANUAL.txt | 9 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 1 | ||||
-rw-r--r-- | test/command/5646.md | 8 |
3 files changed, 14 insertions, 4 deletions
diff --git a/MANUAL.txt b/MANUAL.txt index 879bef5a9..cc329b972 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -3967,10 +3967,11 @@ Attributes can be set on links and images: (This syntax is compatible with [PHP Markdown Extra] when only `#id` and `.class` are used.) -For HTML and EPUB, all attributes except `width` and `height` (but -including `srcset` and `sizes`) are passed through as is. The other -writers ignore attributes that are not supported by their output -format. +For HTML and EPUB, all known HTML5 attributes except `width` and +`height` (but including `srcset` and `sizes`) are passed through +as is. Unknown attributes are passed through as custom +attributes, with `data-` prepended. The other writers ignore +attributes that are not specifically supported by their output format. The `width` and `height` attributes on images are treated specially. When used without a unit, the unit is assumed to be pixels. However, any of diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index ca44583ab..241479157 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -621,6 +621,7 @@ toAttrs kvs = do if x `Set.member` (html5Attributes <> rdfaAttributes) || ':' `elem` x -- e.g. epub: namespace || "data-" `isPrefixOf` x + || "aria-" `isPrefixOf` x then Just $ customAttribute (fromString x) (toValue y) else Just $ customAttribute (fromString ("data-" ++ x)) (toValue y) diff --git a/test/command/5646.md b/test/command/5646.md new file mode 100644 index 000000000..7fe8f5a5f --- /dev/null +++ b/test/command/5646.md @@ -0,0 +1,8 @@ +``` +% pandoc -t html5 -f markdown +![test](foo){aria-describedby="barbaz"} +^D +<figure> +<img src="foo" aria-describedby="barbaz" alt="" /><figcaption>test</figcaption> +</figure> +``` |