Skip to content

Commit 0f3211c

Browse files
committed
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.
1 parent 196bf96 commit 0f3211c

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/Text/Pandoc/Shared.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,13 @@ onlySimpleTableCells = all isSimpleCell . concat
633633

634634
-- | Detect if a list is tight.
635635
isTightList :: [[Block]] -> Bool
636-
isTightList = all (\item -> firstIsPlain item || null item)
637-
where firstIsPlain (Plain _ : _) = True
638-
firstIsPlain _ = False
636+
isTightList = all isPlainItem
637+
where
638+
isPlainItem [] = True
639+
isPlainItem (Plain _ : _) = True
640+
isPlainItem [BulletList xs] = isTightList xs
641+
isPlainItem [OrderedList _ xs] = isTightList xs
642+
isPlainItem _ = False
639643

640644
-- | Convert a list item containing tasklist syntax (e.g. @[x]@)
641645
-- to using @U+2610 BALLOT BOX@ or @U+2612 BALLOT BOX WITH X@.

test/command/8150.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ Nested bullet lists
1212
</ul>
1313
^D
1414
- L1
15-
1615
- L2
17-
1816
- - L3.1
1917
- L3.2
20-
2118
- L4
2219
```
2320

@@ -34,9 +31,7 @@ Nested ordered lists
3431
</ol>
3532
^D
3633
1. L1
37-
3834
2. L2
39-
4035
3. 1. L3.1
4136
2. L3.2
4237
```
@@ -54,9 +49,7 @@ Ordered list nested below an unordered list
5449
</ul>
5550
^D
5651
- L1
57-
5852
- L2
59-
6053
- 1. L3.1
6154
2. L3.2
6255
```

test/command/lists-inside-definition.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Definition
1010
2. list
1111
^D
1212
\begin{description}
13+
\tightlist
1314
\item[Definition]
1415
\begin{enumerate}
1516
\def\labelenumi{\arabic{enumi}.}
@@ -53,6 +54,7 @@ Definition
5354
- list
5455
^D
5556
\begin{description}
57+
\tightlist
5658
\item[Definition]
5759
\begin{itemize}
5860
\tightlist

0 commit comments

Comments
 (0)