summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-04-13 14:37:28 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-04-13 14:37:28 -0700
commit857fcff7d61100e0ce0872b7e2318c3ad0f9e2fb (patch)
tree55f1a3011480cf7f69c4cb909eb6a57fee78aeba /tests
parent86b4da9dec0f42f2571bb249a082f9ac41fe568d (diff)
parentf22ce4ff283ac48a50d999ee5fad56ac1e4d1dce (diff)
Merge pull request #1240 from neilmayhew/master
Docbook output of Line Blocks
Diffstat (limited to 'tests')
-rw-r--r--tests/Tests/Writers/Docbook.hs52
-rw-r--r--tests/test-pandoc.hs2
-rw-r--r--tests/writer.docbook6
3 files changed, 56 insertions, 4 deletions
diff --git a/tests/Tests/Writers/Docbook.hs b/tests/Tests/Writers/Docbook.hs
new file mode 100644
index 000000000..e815b4f5a
--- /dev/null
+++ b/tests/Tests/Writers/Docbook.hs
@@ -0,0 +1,52 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.Docbook (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+
+docbook :: (ToString a, ToPandoc a) => a -> String
+docbook = writeDocbook def{ writerWrapText = False } . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test docbook "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test docbook "my test" (X,Y)
+-}
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test docbook
+
+lineblock :: Blocks
+lineblock = para ("some text" <> linebreak <>
+ "and more lines" <> linebreak <>
+ "and again")
+lineblock_out :: String
+lineblock_out = "<literallayout>some text\n" ++
+ "and more lines\n" ++
+ "and again</literallayout>"
+
+tests :: [Test]
+tests = [ testGroup "line blocks"
+ [ "none" =: para "This is a test"
+ =?> "<para>\n This is a test\n</para>"
+ , "basic" =: lineblock
+ =?> lineblock_out
+ , "blockquote" =: blockQuote lineblock
+ =?> ("<blockquote>\n" ++ lineblock_out ++ "\n</blockquote>")
+ , "footnote" =: para ("This is a test" <> note lineblock <> " of footnotes")
+ =?> ("<para>\n This is a test<footnote>\n" ++
+ lineblock_out ++
+ "\n </footnote> of footnotes\n</para>")
+ ]
+ ]
diff --git a/tests/test-pandoc.hs b/tests/test-pandoc.hs
index 74f8e5044..a7d4fca01 100644
--- a/tests/test-pandoc.hs
+++ b/tests/test-pandoc.hs
@@ -12,6 +12,7 @@ import qualified Tests.Readers.RST
import qualified Tests.Writers.ConTeXt
import qualified Tests.Writers.LaTeX
import qualified Tests.Writers.HTML
+import qualified Tests.Writers.Docbook
import qualified Tests.Writers.Native
import qualified Tests.Writers.Markdown
import qualified Tests.Shared
@@ -27,6 +28,7 @@ tests = [ testGroup "Old" Tests.Old.tests
, testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
, testGroup "LaTeX" Tests.Writers.LaTeX.tests
, testGroup "HTML" Tests.Writers.HTML.tests
+ , testGroup "Docbook" Tests.Writers.Docbook.tests
, testGroup "Markdown" Tests.Writers.Markdown.tests
]
, testGroup "Readers"
diff --git a/tests/writer.docbook b/tests/writer.docbook
index d4b3c7efd..9cb9a5359 100644
--- a/tests/writer.docbook
+++ b/tests/writer.docbook
@@ -68,10 +68,8 @@
<para>
Here’s one with a bullet. * criminey.
</para>
- <para>
- There should be a hard line break<literallayout>
-</literallayout>here.
- </para>
+<literallayout>There should be a hard line break
+here.</literallayout>
</sect1>
<sect1 id="block-quotes">
<title>Block Quotes</title>