diff options
Diffstat (limited to 'test/Tests/Writers/Docbook.hs')
-rw-r--r-- | test/Tests/Writers/Docbook.hs | 105 |
1 files changed, 103 insertions, 2 deletions
diff --git a/test/Tests/Writers/Docbook.hs b/test/Tests/Writers/Docbook.hs index f6a047b0b..f517f803a 100644 --- a/test/Tests/Writers/Docbook.hs +++ b/test/Tests/Writers/Docbook.hs @@ -1,8 +1,6 @@ -{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} module Tests.Writers.Docbook (tests) where -import Prelude import Data.Text (unpack) import Test.Tasty import Tests.Helpers @@ -13,9 +11,14 @@ import Text.Pandoc.Builder docbook :: (ToPandoc a) => a -> String docbook = docbookWithOpts def{ writerWrapText = WrapNone } +docbook5 :: (ToPandoc a) => a -> String +docbook5 = docbook5WithOpts def{ writerWrapText = WrapNone } + docbookWithOpts :: ToPandoc a => WriterOptions -> a -> String docbookWithOpts opts = unpack . purely (writeDocbook4 opts) . toPandoc +docbook5WithOpts :: ToPandoc a => WriterOptions -> a -> String +docbook5WithOpts opts = unpack . purely (writeDocbook5 opts) . toPandoc {- "my test" =: X =?> Y @@ -70,6 +73,72 @@ tests = [ testGroup "line blocks" , "</para>" ] ) ] + , testGroup "divs" + [ "admonition" =: divWith ("foo", ["warning"], []) (para "This is a test") + =?> unlines + [ "<warning id=\"foo\">" + , " <para>" + , " This is a test" + , " </para>" + , "</warning>" + ] + , "admonition-with-title" =: + divWith ("foo", ["note"], []) ( + divWith ("foo", ["title"], []) + (plain (text "This is title")) <> + para "This is a test" + ) + =?> unlines + [ "<note id=\"foo\">" + , " <title>This is title</title>" + , " <para>" + , " This is a test" + , " </para>" + , "</note>" + ] + , "admonition-with-title-in-para" =: + divWith ("foo", ["note"], []) ( + divWith ("foo", ["title"], []) + (para "This is title") <> + para "This is a test" + ) + =?> unlines + [ "<note id=\"foo\">" + , " <title>This is title</title>" + , " <para>" + , " This is a test" + , " </para>" + , "</note>" + ] + , "single-child" =: + divWith ("foo", [], []) (para "This is a test") + =?> unlines + [ "<para id=\"foo\">" + , " This is a test" + , "</para>" + ] + , "single-literal-child" =: + divWith ("foo", [], []) lineblock + =?> unlines + [ "<literallayout id=\"foo\">some text" + , "and more lines" + , "and again</literallayout>" + ] + , "multiple-children" =: + divWith ("foo", [], []) ( + para "This is a test" <> + para "This is an another test" + ) + =?> unlines + [ "<anchor id=\"foo\" />" + , "<para>" + , " This is a test" + , "</para>" + , "<para>" + , " This is an another test" + , "</para>" + ] + ] , testGroup "compact lists" [ testGroup "bullet" [ "compact" =: bulletList [plain "a", plain "b", plain "c"] @@ -302,4 +371,36 @@ tests = [ testGroup "line blocks" ] ] ] + , testGroup "section attributes" $ + let + headers = headerWith ("myid1",[],[("role","internal"),("xml:id","anotherid"),("dir","rtl")]) 1 "header1" + <> headerWith ("myid2",[],[("invalidname","value"),("arch","linux"),("dir","invaliddir")]) 1 "header2" + in + [ test docbook5 "sections with attributes (db5)" $ + headers =?> + unlines [ "<section xmlns=\"http://docbook.org/ns/docbook\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:id=\"myid1\" role=\"internal\" dir=\"rtl\">" + , " <title>header1</title>" + , " <para>" + , " </para>" + , "</section>" + , "<section xmlns=\"http://docbook.org/ns/docbook\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:id=\"myid2\">" + , " <title>header2</title>" + , " <para>" + , " </para>" + , "</section>" + ] + , test docbook "sections with attributes (db4)" $ + headers =?> + unlines [ "<sect1 id=\"myid1\" role=\"internal\">" + , " <title>header1</title>" + , " <para>" + , " </para>" + , "</sect1>" + , "<sect1 id=\"myid2\" arch=\"linux\">" + , " <title>header2</title>" + , " <para>" + , " </para>" + , "</sect1>" + ] + ] ] |