git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: Don't add data- prefix to RDFa attributes.

Closes #5403.

commit15958600590de508d0ac0ece01c5de17cf126a8e authorJohn MacFarlane <jgm@berkeley.edu> dateThu 28 Mar 2019, 20:59 (8 years ago) parent4086595
1 file changed+19−2
src/Text/Pandoc/Writers/HTML.hs+19−2
src/Text/Pandoc/Writers/HTML.hs+19−2
@@ -603,7 +603,7 @@ toAttrs kvs = do
603603 return $ mapMaybe (\(x,y) ->
604604 if html5
605605 then
606− if x `Set.member` html5Attributes
606+ if x `Set.member` (html5Attributes <> rdfaAttributes)
607607 || ':' `elem` x -- e.g. epub: namespace
608608 || "data-" `isPrefixOf` x
609609 then Just $ customAttribute (fromString x) (toValue y)
@@ -611,7 +611,7 @@ toAttrs kvs = do
611611 (toValue y)
612612 else
613613 if mbEpubVersion == Just EPUB2 &&
614− not (x `Set.member` html4Attributes ||
614+ not (x `Set.member` (html4Attributes <> rdfaAttributes) ||
615615 "xml:" `isPrefixOf` x)
616616 then Nothing
617617 else Just $ customAttribute (fromString x) (toValue y))
@@ -1471,6 +1471,23 @@ html5Attributes = Set.fromList
14711471 , "wrap"
14721472 ]
14731473
1474+-- See https://en.wikipedia.org/wiki/RDFa, https://www.w3.org/TR/rdfa-primer/
1475+rdfaAttributes :: Set.Set String
1476+rdfaAttributes = Set.fromList
1477+ [ "about"
1478+ , "rel"
1479+ , "rev"
1480+ , "src"
1481+ , "href"
1482+ , "resource"
1483+ , "property"
1484+ , "content"
1485+ , "datatype"
1486+ , "typeof"
1487+ , "vocab"
1488+ , "prefix"
1489+ ]
1490+
14741491html4Attributes :: Set.Set String
14751492html4Attributes = Set.fromList
14761493 [ "abbr"