aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-11-19 08:50:18 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-11-19 08:50:18 -0800
commitdf5ae1c186ed625e25cf6f080ddf24549f7af22e (patch)
treee4e2c7568960f66a945df676984ea9bb2dd1b9ca
parent25bba0cc62dae54b5b5a4a9ba540fa7b1ec54530 (diff)
downloadpandoc-df5ae1c186ed625e25cf6f080ddf24549f7af22e.tar.gz
HTML writer: Don't create invalid `data-` attribute...
for empty attribute key. (It would be better to make these unrepresentable in the type system, but for now this is an improvement.) Closes #7546.
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs1
-rw-r--r--test/command/7546.md6
2 files changed, 7 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 0a4c47387..247cddfc9 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -633,6 +633,7 @@ toAttrs kvs = do
return (keys, attrs)
else return (Set.insert k keys, addAttr html5 mbEpubVersion k v attrs)
addAttr html5 mbEpubVersion x y
+ | T.null x = id -- see #7546
| html5
= if x `Set.member` (html5Attributes <> rdfaAttributes)
|| T.any (== ':') x -- e.g. epub: namespace
diff --git a/test/command/7546.md b/test/command/7546.md
new file mode 100644
index 000000000..aed17275e
--- /dev/null
+++ b/test/command/7546.md
@@ -0,0 +1,6 @@
+```
+% pandoc -t html -f native
+Span ("", [], [("","")]) []
+^D
+<span></span>
+```