git.iko.soy/typeable/pandoc
on master help sign in
RST Writer: Tests for rubrics and heading normalization
4b7ddebNikolay Yakimov
pandoc.cabal+1
@@ -495,6 +495,7 @@ Test-Suite test-pandoc
495 Tests.Writers.AsciiDoc
495 Tests.Writers.AsciiDoc
496 Tests.Writers.LaTeX
496 Tests.Writers.LaTeX
497 Tests.Writers.Docx
497 Tests.Writers.Docx
498+ Tests.Writers.RST
498 Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded
499 Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded
499 Default-Language: Haskell98
500 Default-Language: Haskell98
500
501
tests/Tests/Writers/RST.hsnew file+79
@@ -0,0 +1,79 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Tests.Writers.RST (tests) where
3+
4+import Test.Framework
5+import Text.Pandoc.Builder
6+import Text.Pandoc
7+import Tests.Helpers
8+import Tests.Arbitrary()
9+
10+infix 4 =:
11+(=:) :: (ToString a, ToPandoc a)
12+ => String -> (a, String) -> Test
13+(=:) = test (writeRST def{ writerHighlight = True } . toPandoc)
14+
15+tests :: [Test]
16+tests = [ testGroup "rubrics"
17+ [ "in list item" =:
18+ bulletList [header 2 (text "foo")] =?>
19+ "- .. rubric:: foo"
20+ , "in definition list item" =:
21+ definitionList [(text "foo", [header 2 (text "bar"),
22+ para $ text "baz"])] =?>
23+ unlines
24+ [ "foo"
25+ , " .. rubric:: bar"
26+ , ""
27+ , " baz"]
28+ , "in block quote" =:
29+ blockQuote (header 1 (text "bar")) =?>
30+ " .. rubric:: bar"
31+ , "with id" =:
32+ blockQuote (headerWith ("foo",[],[]) 1 (text "bar")) =?>
33+ unlines
34+ [ " .. rubric:: bar"
35+ , " :name: foo"]
36+ , "with id class" =:
37+ blockQuote (headerWith ("foo",["baz"],[]) 1 (text "bar")) =?>
38+ unlines
39+ [ " .. rubric:: bar"
40+ , " :name: foo"
41+ , " :class: baz"]
42+ ]
43+ , testGroup "headings"
44+ [ "normal heading" =:
45+ header 1 (text "foo") =?>
46+ unlines
47+ [ "foo"
48+ , "==="]
49+ , "heading levels" =:
50+ header 1 (text "Header 1") <>
51+ header 3 (text "Header 2") <>
52+ header 2 (text "Header 2") <>
53+ header 1 (text "Header 1") <>
54+ header 4 (text "Header 2") <>
55+ header 5 (text "Header 3") <>
56+ header 3 (text "Header 2") =?>
57+ unlines
58+ [ "Header 1"
59+ , "========"
60+ , ""
61+ , "Header 2"
62+ , "--------"
63+ , ""
64+ , "Header 2"
65+ , "--------"
66+ , ""
67+ , "Header 1"
68+ , "========"
69+ , ""
70+ , "Header 2"
71+ , "--------"
72+ , ""
73+ , "Header 3"
74+ , "~~~~~~~~"
75+ , ""
76+ , "Header 2"
77+ , "--------"]
78+ ]
79+ ]
tests/test-pandoc.hs+2
@@ -21,6 +21,7 @@ import qualified Tests.Writers.Markdown
21import qualified Tests.Writers.Plain
21import qualified Tests.Writers.Plain
22import qualified Tests.Writers.AsciiDoc
22import qualified Tests.Writers.AsciiDoc
23import qualified Tests.Writers.Docx
23import qualified Tests.Writers.Docx
24+import qualified Tests.Writers.RST
24import qualified Tests.Shared
25import qualified Tests.Shared
25import qualified Tests.Walk
26import qualified Tests.Walk
26import Text.Pandoc.Shared (inDirectory)
27import Text.Pandoc.Shared (inDirectory)
@@ -40,6 +41,7 @@ tests = [ testGroup "Old" Tests.Old.tests
40 , testGroup "Plain" Tests.Writers.Plain.tests
41 , testGroup "Plain" Tests.Writers.Plain.tests
41 , testGroup "AsciiDoc" Tests.Writers.AsciiDoc.tests
42 , testGroup "AsciiDoc" Tests.Writers.AsciiDoc.tests
42 , testGroup "Docx" Tests.Writers.Docx.tests
43 , testGroup "Docx" Tests.Writers.Docx.tests
44+ , testGroup "RST" Tests.Writers.RST.tests
43 ]
45 ]
44 , testGroup "Readers"
46 , testGroup "Readers"
45 [ testGroup "LaTeX" Tests.Readers.LaTeX.tests
47 [ testGroup "LaTeX" Tests.Readers.LaTeX.tests