aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-10-28 10:06:28 -0700
committerJohn MacFarlane <[email protected]>2023-10-28 10:07:13 -0700
commit0f3211c3391cd9e1c638772ddce553f810c0bccc (patch)
treea513f42bdb416f6185191a82aba7998dbaf57462 /src
parent196bf9693215eb45efd365295e27c3d840d31f54 (diff)
Shared: improve isTightList...
so that it recognizes an item containing only a list which is itself tight as potentially an item in a tight list. Closes #9161.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Shared.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 92269ddec..1e68bdd10 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -633,9 +633,13 @@ onlySimpleTableCells = all isSimpleCell . concat
-- | Detect if a list is tight.
isTightList :: [[Block]] -> Bool
-isTightList = all (\item -> firstIsPlain item || null item)
- where firstIsPlain (Plain _ : _) = True
- firstIsPlain _ = False
+isTightList = all isPlainItem
+ where
+ isPlainItem [] = True
+ isPlainItem (Plain _ : _) = True
+ isPlainItem [BulletList xs] = isTightList xs
+ isPlainItem [OrderedList _ xs] = isTightList xs
+ isPlainItem _ = False
-- | Convert a list item containing tasklist syntax (e.g. @[x]@)
-- to using @U+2610 BALLOT BOX@ or @U+2612 BALLOT BOX WITH X@.