diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs
index 2d6ce3020..e1b62f02d 100644
--- a/src/Text/Pandoc/Writers/Docbook.hs
+++ b/src/Text/Pandoc/Writers/Docbook.hs
@@ -185,10 +185,13 @@ blockToDocbook _ (CodeBlock (_,classes,_) str) =
else languagesByExtension . map toLower $ s
langs = concatMap langsFrom classes
blockToDocbook opts (BulletList lst) =
- inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst
+ let attribs = case lst of
+ ((Plain _:_):_) -> [("spacing", "compact")]
+ _ -> []
+ in inTags True "itemizedlist" attribs $ listItemsToDocbook opts lst
blockToDocbook _ (OrderedList _ []) = empty
blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) =
- let attribs = case numstyle of
+ let numeration = case numstyle of
DefaultStyle -> []
Decimal -> [("numeration", "arabic")]
Example -> [("numeration", "arabic")]
@@ -196,14 +199,21 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) =
LowerAlpha -> [("numeration", "loweralpha")]
UpperRoman -> [("numeration", "upperroman")]
LowerRoman -> [("numeration", "lowerroman")]
- items = if start == 1
- then listItemsToDocbook opts (first:rest)
- else (inTags True "listitem" [("override",show start)]
- (blocksToDocbook opts $ map plainToPara first)) $$
- listItemsToDocbook opts rest
+ spacing = case first of
+ (Plain _:_) -> [("spacing", "compact")]
+ _ -> []
+ attribs = numeration ++ spacing
+ items = if start == 1
+ then listItemsToDocbook opts (first:rest)
+ else (inTags True "listitem" [("override",show start)]
+ (blocksToDocbook opts $ map plainToPara first)) $$
+ listItemsToDocbook opts rest
in inTags True "orderedlist" attribs items
blockToDocbook opts (DefinitionList lst) =
- inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst
+ let attribs = case lst of
+ ((_, (Plain _:_):_):_) -> [("spacing", "compact")]
+ _ -> []
+ in inTags True "variablelist" attribs $ deflistItemsToDocbook opts lst
blockToDocbook _ (RawBlock f str)
| f == "docbook" = text str -- raw XML block
| f == "html" = text str -- allow html for backwards compatibility
diff --git a/tests/Tests/Writers/Docbook.hs b/tests/Tests/Writers/Docbook.hs
index e815b4f5a..97126b473 100644
--- a/tests/Tests/Writers/Docbook.hs
+++ b/tests/Tests/Writers/Docbook.hs
@@ -31,22 +31,199 @@ lineblock :: Blocks
lineblock = para ("some text" <> linebreak <>
"and more lines" <> linebreak <>
"and again")
-lineblock_out :: String
-lineblock_out = "some text\n" ++
- "and more lines\n" ++
- "and again"
+lineblock_out :: [String]
+lineblock_out = [ "some text"
+ , "and more lines"
+ , "and again"
+ ]
tests :: [Test]
tests = [ testGroup "line blocks"
[ "none" =: para "This is a test"
- =?> "\n This is a test\n"
+ =?> unlines
+ [ ""
+ , " This is a test"
+ , ""
+ ]
, "basic" =: lineblock
- =?> lineblock_out
+ =?> unlines lineblock_out
, "blockquote" =: blockQuote lineblock
- =?> ("
\n" ++ lineblock_out ++ "\n
")
- , "footnote" =: para ("This is a test" <> note lineblock <> " of footnotes")
- =?> ("\n This is a test\n" ++
- lineblock_out ++
- "\n of footnotes\n")
+ =?> unlines
+ ( [ "" ] ++
+ lineblock_out ++
+ [ "
" ]
+ )
+ , "footnote" =: para ("This is a test" <>
+ note lineblock <>
+ " of footnotes")
+ =?> unlines
+ ( [ ""
+ , " This is a test" ] ++
+ lineblock_out ++
+ [ " of footnotes"
+ , "" ]
+ )
+ ]
+ , testGroup "compact lists"
+ [ testGroup "bullet"
+ [ "compact" =: bulletList [plain "a", plain "b", plain "c"]
+ =?> unlines
+ [ ""
+ , " "
+ , " "
+ , " a"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " b"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " c"
+ , " "
+ , " "
+ , ""
+ ]
+ , "loose" =: bulletList [para "a", para "b", para "c"]
+ =?> unlines
+ [ ""
+ , " "
+ , " "
+ , " a"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " b"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " c"
+ , " "
+ , " "
+ , ""
+ ]
+ ]
+ , testGroup "ordered"
+ [ "compact" =: orderedList [plain "a", plain "b", plain "c"]
+ =?> unlines
+ [ ""
+ , " "
+ , " "
+ , " a"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " b"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " c"
+ , " "
+ , " "
+ , ""
+ ]
+ , "loose" =: orderedList [para "a", para "b", para "c"]
+ =?> unlines
+ [ ""
+ , " "
+ , " "
+ , " a"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " b"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " c"
+ , " "
+ , " "
+ , ""
+ ]
+ ]
+ , testGroup "definition"
+ [ "compact" =: definitionList [ ("an", [plain "apple" ])
+ , ("a", [plain "banana"])
+ , ("an", [plain "orange"])]
+ =?> unlines
+ [ ""
+ , " "
+ , " "
+ , " an"
+ , " "
+ , " "
+ , " "
+ , " apple"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " "
+ , " a"
+ , " "
+ , " "
+ , " "
+ , " banana"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " "
+ , " an"
+ , " "
+ , " "
+ , " "
+ , " orange"
+ , " "
+ , " "
+ , " "
+ , ""
+ ]
+ , "loose" =: definitionList [ ("an", [para "apple" ])
+ , ("a", [para "banana"])
+ , ("an", [para "orange"])]
+ =?> unlines
+ [ ""
+ , " "
+ , " "
+ , " an"
+ , " "
+ , " "
+ , " "
+ , " apple"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " "
+ , " a"
+ , " "
+ , " "
+ , " "
+ , " banana"
+ , " "
+ , " "
+ , " "
+ , " "
+ , " "
+ , " an"
+ , " "
+ , " "
+ , " "
+ , " orange"
+ , " "
+ , " "
+ , " "
+ , ""
+ ]
+ ]
]
]
diff --git a/tests/writer.docbook b/tests/writer.docbook
index 9cb9a5359..26dcbadaa 100644
--- a/tests/writer.docbook
+++ b/tests/writer.docbook
@@ -93,7 +93,7 @@ sub status {
A list:
-
+
item one
@@ -156,7 +156,7 @@ These should not be escaped: \$ \\ \> \[ \{
Asterisks tight:
-
+
asterisk 1
@@ -196,7 +196,7 @@ These should not be escaped: \$ \\ \> \[ \{
Pluses tight:
-
+
Plus 1
@@ -236,7 +236,7 @@ These should not be escaped: \$ \\ \> \[ \{
Minuses tight:
-
+
Minus 1
@@ -279,7 +279,7 @@ These should not be escaped: \$ \\ \> \[ \{
Tight:
-
+
First
@@ -299,7 +299,7 @@ These should not be escaped: \$ \\ \> \[ \{
and:
-
+
One
@@ -383,17 +383,17 @@ These should not be escaped: \$ \\ \> \[ \{
Nested
-
+
Tab
-
+
Tab
-
+
Tab
@@ -407,7 +407,7 @@ These should not be escaped: \$ \\ \> \[ \{
Here’s another:
-
+
First
@@ -417,7 +417,7 @@ These should not be escaped: \$ \\ \> \[ \{
Second:
-
+
Fee
@@ -454,7 +454,7 @@ These should not be escaped: \$ \\ \> \[ \{
Second:
-
+
Fee
@@ -508,7 +508,7 @@ These should not be escaped: \$ \\ \> \[ \{
Fancy list markers
-
+
begins with 2
@@ -521,7 +521,7 @@ These should not be escaped: \$ \\ \> \[ \{
with a continuation
-
+
sublist with roman numerals, starting with 4
@@ -531,7 +531,7 @@ These should not be escaped: \$ \\ \> \[ \{
more items
-
+
a subsublist
@@ -550,22 +550,22 @@ These should not be escaped: \$ \\ \> \[ \{
Nesting:
-
+
Upper Alpha
-
+
Upper Roman.
-
+
Decimal start with 6
-
+
Lower alpha with paren
@@ -581,7 +581,7 @@ These should not be escaped: \$ \\ \> \[ \{
Autonumbering:
-
+
Autonumber.
@@ -591,7 +591,7 @@ These should not be escaped: \$ \\ \> \[ \{
More.
-
+
Nested.
@@ -616,7 +616,7 @@ These should not be escaped: \$ \\ \> \[ \{
Tight using spaces:
-
+
apple
@@ -651,7 +651,7 @@ These should not be escaped: \$ \\ \> \[ \{
Tight using tabs:
-
+
apple
@@ -757,7 +757,7 @@ These should not be escaped: \$ \\ \> \[ \{
Multiple definitions, tight:
-
+
apple
@@ -841,7 +841,7 @@ These should not be escaped: \$ \\ \> \[ \{
orange fruit
-
+
sublist
@@ -1051,7 +1051,7 @@ These should not be escaped: \$ \\ \> \[ \{
LaTeX
-
+
@@ -1097,7 +1097,7 @@ These should not be escaped: \$ \\ \> \[ \{
These shouldn’t be math:
-
+
To get the famous equation, write $e = mc^2$.
@@ -1130,7 +1130,7 @@ These should not be escaped: \$ \\ \> \[ \{
Here is some unicode:
-
+
I hat: Î
@@ -1316,7 +1316,7 @@ These should not be escaped: \$ \\ \> \[ \{
With an ampersand:
http://example.com/?foo=1&bar=2
-
+
In a list?
@@ -1414,7 +1414,7 @@ or here: <http://example.com/>
-
+
And in list items.