2011-01-22 05:50:18 +01:00
|
|
|
{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
|
2011-01-21 19:23:41 +01:00
|
|
|
module Tests.Writers.ConTeXt (tests) where
|
|
|
|
|
|
|
|
import Test.Framework
|
|
|
|
import Text.Pandoc.Builder
|
|
|
|
import Text.Pandoc
|
|
|
|
import Tests.Helpers
|
2011-01-22 21:18:59 +01:00
|
|
|
import Tests.Arbitrary()
|
2011-01-21 19:23:41 +01:00
|
|
|
|
2011-01-22 05:50:18 +01:00
|
|
|
context :: (ToString a, ToPandoc a) => a -> String
|
2012-07-27 07:59:56 +02:00
|
|
|
context = writeConTeXt def . toPandoc
|
2011-01-21 19:23:41 +01:00
|
|
|
|
2011-01-22 21:18:59 +01:00
|
|
|
context' :: (ToString a, ToPandoc a) => a -> String
|
2012-07-27 07:59:56 +02:00
|
|
|
context' = writeConTeXt def{ writerWrapText = False } . toPandoc
|
2011-01-22 21:18:59 +01:00
|
|
|
|
2011-01-22 05:50:18 +01:00
|
|
|
{-
|
|
|
|
"my test" =: X =?> Y
|
|
|
|
|
|
|
|
is shorthand for
|
|
|
|
|
|
|
|
test context "my test" $ X =?> Y
|
|
|
|
|
|
|
|
which is in turn shorthand for
|
|
|
|
|
|
|
|
test context "my test" (X,Y)
|
|
|
|
-}
|
|
|
|
|
2012-02-05 22:23:06 +01:00
|
|
|
infix 4 =:
|
2011-01-22 05:50:18 +01:00
|
|
|
(=:) :: (ToString a, ToPandoc a)
|
|
|
|
=> String -> (a, String) -> Test
|
|
|
|
(=:) = test context
|
2011-01-21 19:23:41 +01:00
|
|
|
|
|
|
|
tests :: [Test]
|
|
|
|
tests = [ testGroup "inline code"
|
2012-06-28 00:05:13 +02:00
|
|
|
[ "with '}'" =: code "}" =?> "\\mono{\\}}"
|
2011-01-22 05:50:18 +01:00
|
|
|
, "without '}'" =: code "]" =?> "\\type{]}"
|
2011-01-22 21:18:59 +01:00
|
|
|
, property "code property" $ \s -> null s ||
|
|
|
|
if '{' `elem` s || '}' `elem` s
|
|
|
|
then (context' $ code s) == "\\mono{" ++
|
|
|
|
(context' $ str s) ++ "}"
|
|
|
|
else (context' $ code s) == "\\type{" ++ s ++ "}"
|
2011-01-21 19:23:41 +01:00
|
|
|
]
|
|
|
|
, testGroup "headers"
|
|
|
|
[ "level 1" =:
|
2011-12-31 03:21:54 +01:00
|
|
|
header 1 "My header" =?> "\\section[my-header]{My header}"
|
2011-01-22 05:50:18 +01:00
|
|
|
]
|
|
|
|
, testGroup "bullet lists"
|
|
|
|
[ "nested" =:
|
|
|
|
bulletList [plain (text "top")
|
|
|
|
,bulletList [plain (text "next")
|
|
|
|
,bulletList [plain (text "bot")]]]
|
2011-01-26 18:09:32 +01:00
|
|
|
=?> [_LIT|
|
2011-01-22 05:50:18 +01:00
|
|
|
\startitemize
|
|
|
|
\item
|
|
|
|
top
|
|
|
|
\item
|
|
|
|
\startitemize
|
|
|
|
\item
|
|
|
|
next
|
|
|
|
\item
|
|
|
|
\startitemize
|
2011-01-29 18:04:05 +01:00
|
|
|
\item
|
|
|
|
bot
|
2011-01-22 05:50:18 +01:00
|
|
|
\stopitemize
|
|
|
|
\stopitemize
|
|
|
|
\stopitemize|]
|
2011-01-21 19:23:41 +01:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|