pandoc/test/Tests/Readers/Man.hs

95 lines
2.7 KiB
Haskell
Raw Normal View History

2018-02-25 01:34:17 +01:00
{-# LANGUAGE OverloadedStrings #-}
module Tests.Readers.Man (tests) where
2018-05-09 19:40:37 +02:00
import Prelude
2018-02-25 01:34:17 +01:00
import Data.Text (Text)
import Test.Tasty
import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
2018-05-09 02:24:45 +02:00
import Text.Pandoc.Readers.Man
2018-02-25 01:34:17 +01:00
2018-05-09 02:24:45 +02:00
man :: Text -> Pandoc
man = purely $ readMan def
infix 4 =:
(=:) :: ToString c
=> String -> (Text, c) -> TestTree
(=:) = test man
2018-02-25 01:34:17 +01:00
tests :: [TestTree]
2018-05-09 02:24:45 +02:00
tests = [
-- .SH "HEllo bbb" "aaa"" as"
testGroup "Macros" [
2018-10-13 23:57:15 +02:00
"Bold" =:
".B foo"
=?> (para $ strong "foo")
, "Italic" =:
".I bar\n"
=?> (para $ emph "bar")
, "BoldItalic" =:
".BI foo bar"
2018-10-19 23:59:11 +02:00
=?> (para $ strong $ emph $ text "foo bar")
2018-10-13 23:57:15 +02:00
, "H1" =:
".SH The header\n"
2018-10-19 23:59:11 +02:00
=?> header 2 (text "The header")
2018-10-13 23:57:15 +02:00
, "H2" =:
".SS \"The header 2\""
2018-10-19 23:59:11 +02:00
=?> header 3 (text "The header 2")
2018-10-13 23:57:15 +02:00
, "Macro args" =:
".B \"single arg with \"\"Q\"\"\""
2018-10-19 23:59:11 +02:00
=?> (para $ strong $ text "single arg with \"Q\"")
2018-10-13 23:57:15 +02:00
, "comment" =:
".\\\"bla\naaa"
=?> (para $ str "aaa")
2018-10-13 23:57:15 +02:00
, "link" =:
".BR aa (1)"
2018-10-16 02:12:06 +02:00
=?> (para $ link "../1/aa.1" "aa" (strong $ str "aa") <> (strong $ str " (1)"))
2018-10-13 23:57:15 +02:00
],
testGroup "Escapes" [
"fonts" =:
"aa\\fIbb\\fRcc"
=?> (para $ str "aa" <> (emph $ str "bb") <> str "cc")
, "skip" =:
"a\\%\\{\\}\\\n\\:b\\0"
2018-10-16 02:12:06 +02:00
=?> (para $ str "ab")
2018-10-13 23:57:15 +02:00
, "replace" =:
"\\-\\ \\\\\\[lq]\\[rq]\\[em]\\[en]\\*(lq\\*(rq"
2018-10-19 23:59:11 +02:00
=?> (para $ text "- \\“”—–“”")
2018-10-13 23:57:15 +02:00
, "replace2" =:
"\\t\\e\\`\\^\\|\\'" =?> (para $ text "\\` `")
, "comment with \\\"" =:
"Foo \\\" bar\n" =?> (para $ text "Foo")
, "comment with \\#" =:
"Foo\\#\nbar\n" =?> (para $ text "Foobar")
, "two letter escapes" =:
"\\(oA\\(~O" =?> (para $ text "ÅÕ")
, "bracketed escapes" =:
"\\[oA]\\[~O]\\[Do]\\[Ye]\\[product]" =?> (para $ text "ÅÕ$¥∏")
, "unicode escapes" =:
"\\[u2020]" =?> (para $ text "")
, "unicode escapes (combined)" =:
"\\[u0075_u0301]" =?> (para $ text "")
2018-10-13 23:57:15 +02:00
],
testGroup "Lists" [
"bullet" =:
".IP\nfirst\n.IP\nsecond"
=?> bulletList [para $ str "first", para $ str "second"]
2018-10-19 08:53:33 +02:00
, "ordered" =:
2018-10-13 23:57:15 +02:00
".IP 1 a\nfirst\n.IP 2 a\nsecond"
=?> orderedListWith (1,Decimal,DefaultDelim) [para $ str "first", para $ str "second"]
2018-10-13 23:57:15 +02:00
, "upper" =:
".IP A a\nfirst\n.IP B a\nsecond"
=?> orderedListWith (1,UpperAlpha,DefaultDelim) [para $ str "first", para $ str "second"]
2018-10-13 23:57:15 +02:00
, "nested" =:
".IP\nfirst\n.RS\n.IP\n1a\n.IP\n1b\n.RE"
=?> bulletList [(para $ str "first") <> (bulletList [para $ str "1a", para $ str "1b"])]
2018-10-13 23:57:15 +02:00
],
testGroup "CodeBlocks" [
"cb1"=:
".nf\naa\n\tbb\n.fi"
=?> codeBlock "aa\n\tbb"
]
2018-05-09 02:24:45 +02:00
]