2015-05-13 20:39:01 -07:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Tests.Readers.HTML (tests) where
|
|
|
|
|
2017-03-14 17:05:36 +01:00
|
|
|
import Test.Tasty
|
2015-05-13 20:39:01 -07:00
|
|
|
import Tests.Helpers
|
|
|
|
import Text.Pandoc
|
2017-03-04 13:03:41 +01:00
|
|
|
import Text.Pandoc.Arbitrary ()
|
|
|
|
import Text.Pandoc.Builder
|
2017-06-10 18:26:44 +02:00
|
|
|
import Data.Text (Text)
|
2015-05-13 20:39:01 -07:00
|
|
|
|
2017-06-10 18:26:44 +02:00
|
|
|
html :: Text -> Pandoc
|
2016-12-01 12:47:05 -05:00
|
|
|
html = purely $ readHtml def
|
2015-05-13 20:39:01 -07:00
|
|
|
|
2017-03-14 17:05:36 +01:00
|
|
|
tests :: [TestTree]
|
2015-05-13 20:39:01 -07:00
|
|
|
tests = [ testGroup "base tag"
|
|
|
|
[ test html "simple" $
|
2016-03-10 19:59:55 -08:00
|
|
|
"<head><base href=\"http://www.w3schools.com/images/foo\" ></head><body><img src=\"stickman.gif\" alt=\"Stickman\"></head>" =?>
|
2015-05-13 20:39:01 -07:00
|
|
|
plain (image "http://www.w3schools.com/images/stickman.gif" "" (text "Stickman"))
|
|
|
|
, test html "slash at end of base" $
|
|
|
|
"<head><base href=\"http://www.w3schools.com/images/\" ></head><body><img src=\"stickman.gif\" alt=\"Stickman\"></head>" =?>
|
|
|
|
plain (image "http://www.w3schools.com/images/stickman.gif" "" (text "Stickman"))
|
2016-03-10 19:59:55 -08:00
|
|
|
, test html "slash at beginning of href" $
|
|
|
|
"<head><base href=\"http://www.w3schools.com/images/\" ></head><body><img src=\"/stickman.gif\" alt=\"Stickman\"></head>" =?>
|
|
|
|
plain (image "http://www.w3schools.com/stickman.gif" "" (text "Stickman"))
|
2015-05-13 20:39:01 -07:00
|
|
|
, test html "absolute URL" $
|
|
|
|
"<head><base href=\"http://www.w3schools.com/images/\" ></head><body><img src=\"http://example.com/stickman.gif\" alt=\"Stickman\"></head>" =?>
|
|
|
|
plain (image "http://example.com/stickman.gif" "" (text "Stickman"))
|
|
|
|
]
|
2016-11-13 22:41:11 +01:00
|
|
|
, testGroup "anchors"
|
|
|
|
[ test html "anchor without href" $ "<a name=\"anchor\"/>" =?>
|
|
|
|
plain (spanWith ("anchor",[],[]) mempty)
|
|
|
|
]
|
2017-06-27 09:19:37 +01:00
|
|
|
, testGroup "lang"
|
|
|
|
[ test html "lang on <html>" $ "<html lang=\"es\">hola" =?>
|
|
|
|
setMeta "lang" (text "es") (doc (plain (text "hola")))
|
|
|
|
, 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")))
|
|
|
|
]
|
2015-05-13 20:39:01 -07:00
|
|
|
]
|