2013-01-23 08:47:43 -08:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2011-01-21 10:23:41 -08:00
|
|
|
module Tests.Writers.ConTeXt (tests) where
|
|
|
|
|
|
|
|
import Test.Framework
|
|
|
|
import Text.Pandoc.Builder
|
|
|
|
import Text.Pandoc
|
|
|
|
import Tests.Helpers
|
2011-01-22 12:18:59 -08:00
|
|
|
import Tests.Arbitrary()
|
2011-01-21 10:23:41 -08:00
|
|
|
|
2011-01-21 20:50:18 -08:00
|
|
|
context :: (ToString a, ToPandoc a) => a -> String
|
2012-07-26 22:59:56 -07:00
|
|
|
context = writeConTeXt def . toPandoc
|
2011-01-21 10:23:41 -08:00
|
|
|
|
2011-01-22 12:18:59 -08:00
|
|
|
context' :: (ToString a, ToPandoc a) => a -> String
|
2015-12-11 15:58:11 -08:00
|
|
|
context' = writeConTeXt def{ writerWrapText = WrapNone } . toPandoc
|
2011-01-22 12:18:59 -08:00
|
|
|
|
2011-01-21 20:50:18 -08: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 13:23:06 -08:00
|
|
|
infix 4 =:
|
2011-01-21 20:50:18 -08:00
|
|
|
(=:) :: (ToString a, ToPandoc a)
|
|
|
|
=> String -> (a, String) -> Test
|
|
|
|
(=:) = test context
|
2011-01-21 10:23:41 -08:00
|
|
|
|
|
|
|
tests :: [Test]
|
|
|
|
tests = [ testGroup "inline code"
|
2012-06-27 15:05:13 -07:00
|
|
|
[ "with '}'" =: code "}" =?> "\\mono{\\}}"
|
2011-01-21 20:50:18 -08:00
|
|
|
, "without '}'" =: code "]" =?> "\\type{]}"
|
2011-01-22 12:18:59 -08: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 10:23:41 -08:00
|
|
|
]
|
|
|
|
, testGroup "headers"
|
|
|
|
[ "level 1" =:
|
2012-10-29 22:45:52 -07:00
|
|
|
headerWith ("my-header",[],[]) 1 "My header" =?> "\\section[my-header]{My header}"
|
2011-01-21 20:50:18 -08:00
|
|
|
]
|
|
|
|
, testGroup "bullet lists"
|
|
|
|
[ "nested" =:
|
2013-01-07 20:58:12 -08:00
|
|
|
bulletList [
|
|
|
|
plain (text "top")
|
2013-01-23 08:47:43 -08:00
|
|
|
<> bulletList [
|
|
|
|
plain (text "next")
|
|
|
|
<> bulletList [plain (text "bot")]
|
|
|
|
]
|
|
|
|
] =?> unlines
|
|
|
|
[ "\\startitemize[packed]"
|
|
|
|
, "\\item"
|
|
|
|
, " top"
|
|
|
|
, " \\startitemize[packed]"
|
|
|
|
, " \\item"
|
|
|
|
, " next"
|
|
|
|
, " \\startitemize[packed]"
|
|
|
|
, " \\item"
|
|
|
|
, " bot"
|
|
|
|
, " \\stopitemize"
|
|
|
|
, " \\stopitemize"
|
|
|
|
, "\\stopitemize" ]
|
2011-01-21 10:23:41 -08:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|