2013-01-23 08:47:43 -08:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2011-01-29 16:26:00 -08:00
|
|
|
module Tests.Writers.HTML (tests) where
|
|
|
|
|
|
|
|
import Test.Framework
|
|
|
|
import Text.Pandoc.Builder
|
|
|
|
import Text.Pandoc
|
|
|
|
import Tests.Helpers
|
|
|
|
import Tests.Arbitrary()
|
2013-03-05 22:09:42 -08:00
|
|
|
import Text.Highlighting.Kate (languages) -- null if no hl support
|
2011-01-29 16:26:00 -08:00
|
|
|
|
|
|
|
html :: (ToString a, ToPandoc a) => a -> String
|
2012-07-26 22:59:56 -07:00
|
|
|
html = writeHtmlString def{ writerWrapText = False } . toPandoc
|
2011-01-29 16:26:00 -08: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 13:23:06 -08:00
|
|
|
infix 4 =:
|
2011-01-29 16:26:00 -08:00
|
|
|
(=:) :: (ToString a, ToPandoc a)
|
|
|
|
=> String -> (a, String) -> Test
|
|
|
|
(=:) = test html
|
|
|
|
|
|
|
|
tests :: [Test]
|
|
|
|
tests = [ testGroup "inline code"
|
|
|
|
[ "basic" =: code "@&" =?> "<code>@&</code>"
|
|
|
|
, "haskell" =: codeWith ("",["haskell"],[]) ">>="
|
|
|
|
=?> if null languages
|
|
|
|
then "<code class=\"haskell\">>>=</code>"
|
|
|
|
else "<code class=\"sourceCode haskell\"><span class=\"fu\">>>=</span></code>"
|
|
|
|
, "nolanguage" =: codeWith ("",["nolanguage"],[]) ">>="
|
|
|
|
=?> "<code class=\"nolanguage\">>>=</code>"
|
|
|
|
]
|
2011-02-05 08:16:34 -08:00
|
|
|
, testGroup "images"
|
|
|
|
[ "alt with formatting" =:
|
2011-12-13 14:29:07 -08:00
|
|
|
image "/url" "title" ("my " <> emph "image")
|
2011-02-05 08:16:34 -08:00
|
|
|
=?> "<img src=\"/url\" title=\"title\" alt=\"my image\" />"
|
|
|
|
]
|
2011-01-29 16:26:00 -08:00
|
|
|
]
|