git.iko.soy/typeable/pandoc
on master help sign in
HTML reader: read `data-foo` attribute into `foo`.
0526847John MacFarlane
src/Text/Pandoc/Readers/HTML.hs+2−1
@@ -807,7 +807,8 @@ mathMLToTeXMath s = writeTeX <$> readMathML s
807
807
808toStringAttr :: [(Text, Text)] -> [(String, String)]
808toStringAttr :: [(Text, Text)] -> [(String, String)]
809toStringAttr = map go
809toStringAttr = map go
810− where go (x,y) = (T.unpack x, T.unpack y)
810+ where go (x,y) = (T.unpack (fromMaybe x $ T.stripPrefix "data-" x),
811+ T.unpack y)
811
812
812pScriptMath :: PandocMonad m => TagParser m Inlines
813pScriptMath :: PandocMonad m => TagParser m Inlines
813pScriptMath = try $ do
814pScriptMath = try $ do
test/Tests/Readers/HTML.hs+1−1
@@ -83,7 +83,7 @@ tests = [ testGroup "base tag"
83 , test htmlNativeDivs "<main role=X> becomes <div role=X>" $ "<main role=foobar>hello</main>" =?>
83 , test htmlNativeDivs "<main role=X> becomes <div role=X>" $ "<main role=foobar>hello</main>" =?>
84 doc (divWith ("", [], [("role", "foobar")]) (plain (text "hello")))
84 doc (divWith ("", [], [("role", "foobar")]) (plain (text "hello")))
85 , test htmlNativeDivs "<main> has attributes preserved" $ "<main id=foo class=bar data-baz=qux>hello</main>" =?>
85 , test htmlNativeDivs "<main> has attributes preserved" $ "<main id=foo class=bar data-baz=qux>hello</main>" =?>
86− doc (divWith ("foo", ["bar"], [("role", "main"), ("data-baz", "qux")]) (plain (text "hello")))
86+ doc (divWith ("foo", ["bar"], [("role", "main"), ("baz", "qux")]) (plain (text "hello")))
87 , test htmlNativeDivs "<main> closes <p>" $ "<p>hello<main>main content</main>" =?>
87 , test htmlNativeDivs "<main> closes <p>" $ "<p>hello<main>main content</main>" =?>
88 doc (para (text "hello") <> divWith ("", [], [("role", "main")]) (plain (text "main content")))
88 doc (para (text "hello") <> divWith ("", [], [("role", "main")]) (plain (text "main content")))
89 , test htmlNativeDivs "<main> followed by text" $ "<main>main content</main>non-main content" =?>
89 , test htmlNativeDivs "<main> followed by text" $ "<main>main content</main>non-main content" =?>