summaryrefslogtreecommitdiff
path: root/test/Tests/Readers
diff options
context:
space:
mode:
authorbucklereed <horridimpfoobarbaz@chammy.info>2017-08-09 17:10:12 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-09 09:10:12 -0700
commitdb55f7c1b243cbc82c70276c7dfb9c0403e369b0 (patch)
tree0a4621dc208124353217f4f46cf3e78ac731c28f /test/Tests/Readers
parentcfa597fc2ac2a6dceb0b3387a2ee885ec75bc7d1 (diff)
HTML reader: parse <main> like <div role=main>. (#3791)
* HTML reader: parse <main> like <div role=main>. * <main> closes <p> and behaves like a block element generally
Diffstat (limited to 'test/Tests/Readers')
-rw-r--r--test/Tests/Readers/HTML.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs
index da6298e76..00a8cfc90 100644
--- a/test/Tests/Readers/HTML.hs
+++ b/test/Tests/Readers/HTML.hs
@@ -11,6 +11,9 @@ import Data.Text (Text)
html :: Text -> Pandoc
html = purely $ readHtml def
+htmlNativeDivs :: Text -> Pandoc
+htmlNativeDivs = purely $ readHtml def { readerExtensions = enableExtension Ext_native_divs $ readerExtensions def }
+
tests :: [TestTree]
tests = [ testGroup "base tag"
[ test html "simple" $
@@ -36,4 +39,16 @@ tests = [ testGroup "base tag"
, test html "xml:lang on <html>" $ "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"es\"><head></head><body>hola</body></html>" =?>
setMeta "lang" (text "es") (doc (plain (text "hola")))
]
+ , testGroup "main"
+ [ test htmlNativeDivs "<main> becomes <div role=main>" $ "<main>hello</main>" =?>
+ doc (divWith ("", [], [("role", "main")]) (plain (text "hello")))
+ , test htmlNativeDivs "<main role=X> becomes <div role=X>" $ "<main role=foobar>hello</main>" =?>
+ doc (divWith ("", [], [("role", "foobar")]) (plain (text "hello")))
+ , test htmlNativeDivs "<main> has attributes preserved" $ "<main id=foo class=bar data-baz=qux>hello</main>" =?>
+ doc (divWith ("foo", ["bar"], [("role", "main"), ("data-baz", "qux")]) (plain (text "hello")))
+ , test htmlNativeDivs "<main> closes <p>" $ "<p>hello<main>main content</main>" =?>
+ doc (para (text "hello") <> divWith ("", [], [("role", "main")]) (plain (text "main content")))
+ , test htmlNativeDivs "<main> followed by text" $ "<main>main content</main>non-main content" =?>
+ doc (divWith ("", [], [("role", "main")]) (plain (text "main content")) <> plain (text "non-main content"))
+ ]
]