git.iko.soy/typeable/pandoc
on master help sign in
HTML reader: don't parse `data-id` as `id` attribute.

And similarly don't parse any `data-X` as `X` when `X` is a valid HTML attribute. Reported in comment on #5415.

commit1433aaa4c35af84fbe00ecf971acd1414da6dea8 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 12 Feb 2020, 08:46 (7 years ago) parentfae8ea3
1 file changed+9−1
src/Text/Pandoc/Readers/HTML.hs+9−1
src/Text/Pandoc/Readers/HTML.hs+9−1
@@ -52,6 +52,7 @@ import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)
5252import Text.Pandoc.Definition
5353import Text.Pandoc.Readers.LaTeX (rawLaTeXInline)
5454import Text.Pandoc.Readers.LaTeX.Types (Macro)
55+import Text.Pandoc.XML (html5Attributes, html4Attributes, rdfaAttributes)
5556import Text.Pandoc.Error
5657import Text.Pandoc.Logging
5758import Text.Pandoc.Options (
@@ -835,7 +836,14 @@ mathMLToTeXMath s = writeTeX <$> readMathML s
835836
836837toStringAttr :: [(Text, Text)] -> [(Text, Text)]
837838toStringAttr = map go
838− where go (x,y) = (fromMaybe x $ T.stripPrefix "data-" x, y)
839+ where
840+ go (x,y) =
841+ case T.stripPrefix "data-" x of
842+ Nothing -> (x,y)
843+ Just x' -> if x' `Set.member` (html5Attributes <>
844+ html4Attributes <> rdfaAttributes)
845+ then (x,y)
846+ else (x',y)
839847
840848pScriptMath :: PandocMonad m => TagParser m Inlines
841849pScriptMath = try $ do