git.iko.soy/typeable/pandoc
on ea6be2e help sign in
39 lines 2.0 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2module Tests.Readers.HTML (tests) where
4import Test.Tasty
5import Tests.Helpers
6import Text.Pandoc
7import Text.Pandoc.Arbitrary ()
8import Text.Pandoc.Builder
9import Data.Text (Text)
11html :: Text -> Pandoc
12html = purely $ readHtml def
14tests :: [TestTree]
15tests = [ testGroup "base tag"
16 [ test html "simple" $
17 "<head><base href=\"http://www.w3schools.com/images/foo\" ></head><body><img src=\"stickman.gif\" alt=\"Stickman\"></head>" =?>
18 plain (image "http://www.w3schools.com/images/stickman.gif" "" (text "Stickman"))
19 , test html "slash at end of base" $
20 "<head><base href=\"http://www.w3schools.com/images/\" ></head><body><img src=\"stickman.gif\" alt=\"Stickman\"></head>" =?>
21 plain (image "http://www.w3schools.com/images/stickman.gif" "" (text "Stickman"))
22 , test html "slash at beginning of href" $
23 "<head><base href=\"http://www.w3schools.com/images/\" ></head><body><img src=\"/stickman.gif\" alt=\"Stickman\"></head>" =?>
24 plain (image "http://www.w3schools.com/stickman.gif" "" (text "Stickman"))
25 , test html "absolute URL" $
26 "<head><base href=\"http://www.w3schools.com/images/\" ></head><body><img src=\"http://example.com/stickman.gif\" alt=\"Stickman\"></head>" =?>
27 plain (image "http://example.com/stickman.gif" "" (text "Stickman"))
28 ]
29 , testGroup "anchors"
30 [ test html "anchor without href" $ "<a name=\"anchor\"/>" =?>
31 plain (spanWith ("anchor",[],[]) mempty)
32 ]
33 , testGroup "lang"
34 [ test html "lang on <html>" $ "<html lang=\"es\">hola" =?>
35 setMeta "lang" (text "es") (doc (plain (text "hola")))
36 , test html "xml:lang on <html>" $ "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"es\"><head></head><body>hola</body></html>" =?>
37 setMeta "lang" (text "es") (doc (plain (text "hola")))
38 ]
39 ]