2013-01-23 17:47:43 +01:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2011-01-30 01:26:00 +01:00
|
|
|
module Tests.Writers.HTML (tests) where
|
|
|
|
|
2017-06-10 23:39:49 +02:00
|
|
|
import Data.Text (unpack)
|
2017-03-14 17:05:36 +01:00
|
|
|
import Test.Tasty
|
2011-01-30 01:26:00 +01:00
|
|
|
import Tests.Helpers
|
2017-03-04 13:03:41 +01:00
|
|
|
import Text.Pandoc
|
|
|
|
import Text.Pandoc.Arbitrary ()
|
|
|
|
import Text.Pandoc.Builder
|
2011-01-30 01:26:00 +01:00
|
|
|
|
2016-07-14 17:54:06 +02:00
|
|
|
html :: (ToPandoc a) => a -> String
|
2017-06-10 23:39:49 +02:00
|
|
|
html = unpack . purely (writeHtml4String def{ writerWrapText = WrapNone }) . toPandoc
|
2011-01-30 01:26:00 +01:00
|
|
|
|
|
|
|
{-
|
|
|
|
"my test" =: X =?> Y
|
|
|
|
|
|
|
|
is shorthand for
|
|
|
|
|
|
|
|
test html "my test" $ X =?> Y
|
|
|
|
|
|
|
|
which is in turn shorthand for
|
|
|
|
|
|
|
|
test html "my test" (X,Y)
|
|
|
|
-}
|
|
|
|
|
2012-02-05 22:23:06 +01:00
|
|
|
infix 4 =:
|
2011-01-30 01:26:00 +01:00
|
|
|
(=:) :: (ToString a, ToPandoc a)
|
2017-03-14 17:05:36 +01:00
|
|
|
=> String -> (a, String) -> TestTree
|
2011-01-30 01:26:00 +01:00
|
|
|
(=:) = test html
|
|
|
|
|
2017-03-14 17:05:36 +01:00
|
|
|
tests :: [TestTree]
|
2011-01-30 01:26:00 +01:00
|
|
|
tests = [ testGroup "inline code"
|
|
|
|
[ "basic" =: code "@&" =?> "<code>@&</code>"
|
|
|
|
, "haskell" =: codeWith ("",["haskell"],[]) ">>="
|
2017-01-22 11:36:30 +01:00
|
|
|
=?> "<code class=\"sourceCode haskell\"><span class=\"fu\">>>=</span></code>"
|
2011-01-30 01:26:00 +01:00
|
|
|
, "nolanguage" =: codeWith ("",["nolanguage"],[]) ">>="
|
|
|
|
=?> "<code class=\"nolanguage\">>>=</code>"
|
|
|
|
]
|
2011-02-05 17:16:34 +01:00
|
|
|
, testGroup "images"
|
|
|
|
[ "alt with formatting" =:
|
2011-12-13 23:29:07 +01:00
|
|
|
image "/url" "title" ("my " <> emph "image")
|
2011-02-05 17:16:34 +01:00
|
|
|
=?> "<img src=\"/url\" title=\"title\" alt=\"my image\" />"
|
|
|
|
]
|
2011-01-30 01:26:00 +01:00
|
|
|
]
|