aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYan Pas <yanp.bugz@gmail.com>2018-10-14 00:57:15 +0300
committerYan Pas <yanp.bugz@gmail.com>2018-10-14 00:57:15 +0300
commit3fed62611ea394b088c49c1de680e74978bb9f82 (patch)
tree3faae8057c260d27f85fea7eb9bb16dbe64cad94
parent07b4d7b297dfc83f47aa1d708b7405a5e4b3cc4f (diff)
downloadpandoc-3fed62611ea394b088c49c1de680e74978bb9f82.tar.gz
tests, commented debug functions
-rw-r--r--src/Text/Pandoc/Readers/Man.hs23
-rw-r--r--test/Tests/Readers/Man.hs77
2 files changed, 70 insertions, 30 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs
index aea53a375..24f8316ef 100644
--- a/src/Text/Pandoc/Readers/Man.hs
+++ b/src/Text/Pandoc/Readers/Man.hs
@@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of man to 'Pandoc' document.
-}
-module Text.Pandoc.Readers.Man (readMan, testFile) where
+module Text.Pandoc.Readers.Man (readMan) where --testFile
import Prelude
import Control.Monad (liftM)
@@ -43,7 +43,7 @@ import Data.Maybe (catMaybes, fromMaybe, isNothing)
import Data.List (intersperse, intercalate)
import qualified Data.Text as T
-import Text.Pandoc.Class (PandocMonad(..), runIOorExplode)
+import Text.Pandoc.Class (PandocMonad(..))
import Text.Pandoc.Definition
import Text.Pandoc.Error (PandocError (PandocParsecError))
import Text.Pandoc.Logging (LogMessage(..))
@@ -94,9 +94,9 @@ instance Default RoffState where
type ManLexer m = ParserT [Char] RoffState m
type ManParser m = ParserT [ManToken] ParserState m
-----
--- testStrr :: [Char] -> Either PandocError Pandoc
--- testStrr s = runPure $ readMan def (T.pack s)
+---- debug functions
+{-
+import Text.Pandoc.Class (runIOorExplode)
printPandoc :: Pandoc -> [Char]
printPandoc (Pandoc m content) =
@@ -104,16 +104,17 @@ printPandoc (Pandoc m content) =
cnt = intercalate "\n" $ map show content
in ttl ++ "\n" ++ cnt
--- strrepr :: Either PandocError Pandoc -> [Char]
--- strrepr obj = case obj of
--- Right x -> printPandoc x
--- Left y -> show y
+testStr :: String -> IO ()
+testStr str = do
+ pand <- runIOorExplode $ readMan def (T.pack str)
+ putStrLn $ printPandoc pand
+
testFile :: FilePath -> IO ()
testFile fname = do
cont <- readFile fname
- pand <- runIOorExplode $ readMan def (T.pack cont)
- putStrLn $ printPandoc pand
+ testStr cont
+-}
----
diff --git a/test/Tests/Readers/Man.hs b/test/Tests/Readers/Man.hs
index 4807095a5..6226099d2 100644
--- a/test/Tests/Readers/Man.hs
+++ b/test/Tests/Readers/Man.hs
@@ -22,23 +22,62 @@ tests :: [TestTree]
tests = [
-- .SH "HEllo bbb" "aaa"" as"
testGroup "Macros" [
- "Bold" =:
- ".B foo"
- =?> (para $ strong "foo")
- , "Italic" =:
- ".I bar\n"
- =?> (para $ emph "bar")
- , "BoldItalic" =:
- ".BI foo bar"
- =?> (para $ strong $ emph $ str "foo bar")
- , "H1" =:
- ".SH The header\n"
- =?> header 2 (str "The header")
- , "H2" =:
- ".SS The header 2"
- =?> header 3 (str "The header 2")
- , "Macro args" =:
- ".B \"single arg with \"\"Q\"\"\""
- =?> (para $ strong $ str "single arg with \"Q\"")
- ]
+ "Bold" =:
+ ".B foo"
+ =?> (para $ strong "foo")
+ , "Italic" =:
+ ".I bar\n"
+ =?> (para $ emph "bar")
+ , "BoldItalic" =:
+ ".BI foo bar"
+ =?> (para $ strong $ emph $ str "foo bar")
+ , "H1" =:
+ ".SH The header\n"
+ =?> header 2 (str "The" <> space <> str "header")
+ , "H2" =:
+ ".SS \"The header 2\""
+ =?> header 3 (str "The header 2")
+ , "Macro args" =:
+ ".B \"single arg with \"\"Q\"\"\""
+ =?> (para $ strong $ str "single arg with \"Q\"")
+ , "comment" =:
+ ".\\\"bla\naaa"
+ =?> (para $ space <> str "aaa")
+ , "link" =:
+ ".BR aa (1)"
+ =?> (para $ fromList [Link nullAttr [Strong [Str "aa"]] ("../1/aa.1","aa"), Strong [Str " (1)",Str ""]])
+ ],
+ testGroup "Escapes" [
+ "fonts" =:
+ "aa\\fIbb\\fRcc"
+ =?> (para $ str "aa" <> (emph $ str "bb") <> str "cc")
+ , "skip" =:
+ "a\\%\\{\\}\\\n\\:b\\0"
+ =?> (para $ fromList $ map Str ["a", "b"])
+ , "replace" =:
+ "\\-\\ \\\\\\[lq]\\[rq]\\[em]\\[en]\\*(lq\\*(rq"
+ =?> (para $ fromList $ map Str ["-", " ", "\\", "“", "”", "—", "–", "«", "»"])
+ , "replace2" =:
+ "\\t\\e\\`\\^\\|\\'"
+ =?> (para $ fromList $ map Str ["\t", "\\", "`", " ", " ", "`"])
+ ],
+ testGroup "Lists" [
+ "bullet" =:
+ ".IP\nfirst\n.IP\nsecond"
+ =?> bulletList [plain $ str "first", plain $ str "second"]
+ , "odrered" =:
+ ".IP 1 a\nfirst\n.IP 2 a\nsecond"
+ =?> orderedListWith (1,Decimal,DefaultDelim) [plain $ str "first", plain $ str "second"]
+ , "upper" =:
+ ".IP A a\nfirst\n.IP B a\nsecond"
+ =?> orderedListWith (1,UpperAlpha,DefaultDelim) [plain $ str "first", plain $ str "second"]
+ , "nested" =:
+ ".IP\nfirst\n.RS\n.IP\n1a\n.IP\n1b\n.RE"
+ =?> fromList [BulletList [[Plain [Str "first"],BulletList [[Plain [Str "1a"]],[Plain [Str "1b"]]]]]]
+ ],
+ testGroup "CodeBlocks" [
+ "cb1"=:
+ ".nf\naa\n\tbb\n.fi"
+ =?> codeBlock "aa\n\tbb"
+ ]
]