2015-05-14 05:39:01 +02:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Tests.Readers.HTML (tests) where
|
|
|
|
|
|
|
|
import Test.Framework
|
|
|
|
import Tests.Helpers
|
|
|
|
import Text.Pandoc
|
2017-03-04 13:03:41 +01:00
|
|
|
import Text.Pandoc.Arbitrary ()
|
|
|
|
import Text.Pandoc.Builder
|
2015-05-14 05:39:01 +02:00
|
|
|
|
|
|
|
html :: String -> Pandoc
|
2016-12-01 18:47:05 +01:00
|
|
|
html = purely $ readHtml def
|
2015-05-14 05:39:01 +02:00
|
|
|
|
|
|
|
tests :: [Test]
|
|
|
|
tests = [ testGroup "base tag"
|
|
|
|
[ test html "simple" $
|
2016-03-11 04:59:55 +01:00
|
|
|
"<head><base href=\"http://www.w3schools.com/images/foo\" ></head><body><img src=\"stickman.gif\" alt=\"Stickman\"></head>" =?>
|
2015-05-14 05:39:01 +02: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-11 04:59:55 +01: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-14 05:39:01 +02: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)
|
|
|
|
]
|
2015-05-14 05:39:01 +02:00
|
|
|
]
|