aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Shared.hs11
-rw-r--r--test/command/5285.md15
2 files changed, 24 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index b1ae9eeed..a945c9355 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -416,7 +416,8 @@ capitalize = walk go
go x = x
-- | Change final list item from @Para@ to @Plain@ if the list contains
--- no other @Para@ blocks.
+-- no other @Para@ blocks. Otherwise (if the list items contain @Para@
+-- blocks besides possibly at the end), turn any @Plain@s into @Para@s (#5285).
compactify :: [Blocks] -- ^ List of list items (each a list of blocks)
-> [Blocks]
compactify [] = []
@@ -426,9 +427,15 @@ compactify items =
(Para a:xs) -> case [Para x | Para x <- concatMap B.toList items] of
-- if this is only Para, change to Plain
[_] -> others ++ [B.fromList (reverse $ Plain a : xs)]
- _ -> items
+ -- if other Paras, it's a loose list, change
+ -- all Plain to Para
+ _ -> map (fmap plainToPara) items
_ -> items
+plainToPara :: Block -> Block
+plainToPara (Plain ils) = Para ils
+plainToPara x = x
+
-- | Like @compactify@, but acts on items of definition lists.
compactifyDL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
compactifyDL items =
diff --git a/test/command/5285.md b/test/command/5285.md
new file mode 100644
index 000000000..780812761
--- /dev/null
+++ b/test/command/5285.md
@@ -0,0 +1,15 @@
+```
+% pandoc -t native
+- a
+
+ b
+- a
+
+- b
+^D
+[BulletList
+ [[Para [Str "a"]
+ ,Para [Str "b"]]
+ ,[Para [Str "a"]]
+ ,[Para [Str "b"]]]]
+```