git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: parse `<header>` as a Div

HTML5 `<header>` elements are treated like `<div>` elements.

commit0794862aacdb5d28616dadc3d681a63c36251212 authorAlbert Krewinkel <albert@zeitkraut.de> dateSat 15 May 2021, 16:36 (5 years ago) parent46baf66
2 files changed+11−5
src/Text/Pandoc/Readers/HTML.hs+2 test/Tests/Readers/HTML.hs+9−5
src/Text/Pandoc/Readers/HTML.hs+2
@@ -205,6 +205,7 @@ block = ((do
205205 | otherwise
206206 -> pDiv
207207 "section" -> pDiv
208+ "header" -> pDiv
208209 "main" -> pDiv
209210 "figure" -> pFigure
210211 "iframe" -> pIframe
@@ -404,6 +405,7 @@ pLineBlock = try $ do
404405isDivLike :: Text -> Bool
405406isDivLike "div" = True
406407isDivLike "section" = True
408+isDivLike "header" = True
407409isDivLike "main" = True
408410isDivLike _ = False
409411
test/Tests/Readers/HTML.hs+9−5
@@ -99,11 +99,15 @@ tests = [ testGroup "base tag"
9999 plain (codeWith ("",["sample"],[]) "Answer is 42")
100100 ]
101101 , testGroup "var"
102− [
103− test html "inline var block" $
104− "<var>result</var>" =?>
105− plain (codeWith ("",["variable"],[]) "result")
106− ]
102+ [ test html "inline var block" $
103+ "<var>result</var>" =?>
104+ plain (codeWith ("",["variable"],[]) "result")
105+ ]
106+ , testGroup "header"
107+ [ test htmlNativeDivs "<header> is parsed as a div" $
108+ "<header id=\"title\">Title</header>" =?>
109+ divWith ("title", mempty, mempty) (plain "Title")
110+ ]
107111 , askOption $ \(QuickCheckTests numtests) ->
108112 testProperty "Round trip" $
109113 withMaxSuccess (if QuickCheckTests numtests == defaultValue