aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/Text/Pandoc/Shared.hs10
-rw-r--r--test/command/8150.md7
-rw-r--r--test/command/lists-inside-definition.md2
3 files changed, 9 insertions, 10 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@.
diff --git a/test/command/8150.md b/test/command/8150.md
index 2feded961..c27a7abd1 100644
--- a/test/command/8150.md
+++ b/test/command/8150.md
@@ -12,12 +12,9 @@ Nested bullet lists
</ul>
^D
- L1
-
- L2
-
- - L3.1
- L3.2
-
- L4
```
@@ -34,9 +31,7 @@ Nested ordered lists
</ol>
^D
1. L1
-
2. L2
-
3. 1. L3.1
2. L3.2
```
@@ -54,9 +49,7 @@ Ordered list nested below an unordered list
</ul>
^D
- L1
-
- L2
-
- 1. L3.1
2. L3.2
```
diff --git a/test/command/lists-inside-definition.md b/test/command/lists-inside-definition.md
index f0cac0d69..e5c6e83c6 100644
--- a/test/command/lists-inside-definition.md
+++ b/test/command/lists-inside-definition.md
@@ -10,6 +10,7 @@ Definition
2. list
^D
\begin{description}
+\tightlist
\item[Definition]
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
@@ -53,6 +54,7 @@ Definition
- list
^D
\begin{description}
+\tightlist
\item[Definition]
\begin{itemize}
\tightlist