2018-03-18 10:46:28 -07:00
|
|
|
{-# LANGUAGE NoImplicitPrelude #-}
|
2014-05-03 22:33:36 -07:00
|
|
|
module Tests.Writers.AsciiDoc (tests) where
|
|
|
|
|
2018-03-18 10:46:28 -07:00
|
|
|
import Prelude
|
2017-06-10 23:39:49 +02:00
|
|
|
import Data.Text (unpack)
|
2017-03-14 17:05:36 +01:00
|
|
|
import Test.Tasty
|
2014-05-03 22:33:36 -07:00
|
|
|
import Tests.Helpers
|
2017-03-04 13:03:41 +01:00
|
|
|
import Text.Pandoc
|
|
|
|
import Text.Pandoc.Arbitrary ()
|
|
|
|
import Text.Pandoc.Builder
|
2014-05-03 22:33:36 -07:00
|
|
|
|
2016-07-14 08:54:06 -07:00
|
|
|
asciidoc :: (ToPandoc a) => a -> String
|
2017-06-10 23:39:49 +02:00
|
|
|
asciidoc = unpack . purely (writeAsciiDoc def{ writerWrapText = WrapNone }) . toPandoc
|
2014-05-03 22:33:36 -07:00
|
|
|
|
2017-03-14 17:05:36 +01:00
|
|
|
tests :: [TestTree]
|
2014-07-20 12:24:53 -07:00
|
|
|
tests = [ testGroup "emphasis"
|
|
|
|
[ test asciidoc "emph word before" $
|
|
|
|
para (text "foo" <> emph (text "bar")) =?>
|
|
|
|
"foo__bar__"
|
|
|
|
, test asciidoc "emph word after" $
|
|
|
|
para (emph (text "foo") <> text "bar") =?>
|
|
|
|
"__foo__bar"
|
|
|
|
, test asciidoc "emph quoted" $
|
|
|
|
para (doubleQuoted (emph (text "foo"))) =?>
|
|
|
|
"``__foo__''"
|
|
|
|
, test asciidoc "strong word before" $
|
|
|
|
para (text "foo" <> strong (text "bar")) =?>
|
|
|
|
"foo**bar**"
|
|
|
|
, test asciidoc "strong word after" $
|
|
|
|
para (strong (text "foo") <> text "bar") =?>
|
|
|
|
"**foo**bar"
|
|
|
|
, test asciidoc "strong quoted" $
|
|
|
|
para (singleQuoted (strong (text "foo"))) =?>
|
|
|
|
"`**foo**'"
|
|
|
|
]
|
|
|
|
, testGroup "tables"
|
2014-05-03 22:33:36 -07:00
|
|
|
[ test asciidoc "empty cells" $
|
|
|
|
simpleTable [] [[mempty],[mempty]] =?> unlines
|
|
|
|
[ "[cols=\"\",]"
|
|
|
|
, "|===="
|
|
|
|
, "|"
|
|
|
|
, "|"
|
|
|
|
, "|===="
|
|
|
|
]
|
|
|
|
, test asciidoc "multiblock cells" $
|
2014-07-20 12:24:53 -07:00
|
|
|
simpleTable [] [[para (text "Para 1") <> para (text "Para 2")]]
|
2014-05-03 22:33:36 -07:00
|
|
|
=?> unlines
|
|
|
|
[ "[cols=\"\",]"
|
|
|
|
, "|====="
|
|
|
|
, "a|"
|
|
|
|
, "Para 1"
|
|
|
|
, ""
|
|
|
|
, "Para 2"
|
|
|
|
, ""
|
|
|
|
, "|====="
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|