summaryrefslogtreecommitdiff
path: root/src/Tests/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-01-29 16:26:00 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-01-29 16:26:00 -0800
commit3b5dbe6fdb3888b263a52e001918b0e97789a38c (patch)
treefacb4bbdaa7f402ad9ebefebdb7587417fa458e1 /src/Tests/Writers
parent22969c1b9cc88225c8bc60ac4e98636051ca7b4c (diff)
Added HTML writer tests for inline code.
Diffstat (limited to 'src/Tests/Writers')
-rw-r--r--src/Tests/Writers/HTML.hs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/Tests/Writers/HTML.hs b/src/Tests/Writers/HTML.hs
new file mode 100644
index 000000000..e13d0dc87
--- /dev/null
+++ b/src/Tests/Writers/HTML.hs
@@ -0,0 +1,41 @@
+{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
+module Tests.Writers.HTML (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+import Text.Pandoc.Highlighting (languages) -- null if no hl support
+
+html :: (ToString a, ToPandoc a) => a -> String
+html = writeHtmlString defaultWriterOptions{ writerWrapText = False } . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test html "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test html "my test" (X,Y)
+-}
+
+infix 5 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test html
+
+tests :: [Test]
+tests = [ testGroup "inline code"
+ [ "basic" =: code "@&" =?> "<code>@&amp;</code>"
+ , "haskell" =: codeWith ("",["haskell"],[]) ">>="
+ =?> if null languages
+ then "<code class=\"haskell\">&gt;&gt;=</code>"
+ else "<code class=\"sourceCode haskell\"><span class=\"fu\">&gt;&gt;=</span></code>"
+ , "nolanguage" =: codeWith ("",["nolanguage"],[]) ">>="
+ =?> "<code class=\"nolanguage\">&gt;&gt;=</code>"
+ ]
+ ]