Skip to content

Commit

Permalink
Shared: improve isTightList...
Browse files Browse the repository at this point in the history
so that it recognizes an item containing only a list which is
itself tight as potentially an item in a tight list.

Closes #9161.
  • Loading branch information
jgm committed Oct 28, 2023
1 parent 196bf96 commit 0f3211c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
10 changes: 7 additions & 3 deletions src/Text/Pandoc/Shared.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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@.
Expand Down
7 changes: 0 additions & 7 deletions test/command/8150.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ Nested bullet lists
</ul>
^D
- L1
- L2
- - L3.1
- L3.2
- L4
```

Expand All @@ -34,9 +31,7 @@ Nested ordered lists
</ol>
^D
1. L1
2. L2
3. 1. L3.1
2. L3.2
```
Expand All @@ -54,9 +49,7 @@ Ordered list nested below an unordered list
</ul>
^D
- L1
- L2
- 1. L3.1
2. L3.2
```
2 changes: 2 additions & 0 deletions test/command/lists-inside-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Definition
2. list
^D
\begin{description}
\tightlist
\item[Definition]
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
Expand Down Expand Up @@ -53,6 +54,7 @@ Definition
- list
^D
\begin{description}
\tightlist
\item[Definition]
\begin{itemize}
\tightlist
Expand Down

0 comments on commit 0f3211c

Please sign in to comment.