Fix --toc-depth regression in 2.8.

Closes #5967.
This commit is contained in:
John MacFarlane 2019-12-07 14:20:41 -08:00
parent 5295607de7
commit 0b54d6282b
2 changed files with 18 additions and 3 deletions

View file

@ -407,9 +407,9 @@ toTableOfContents opts bs =
sectionToListItem :: WriterOptions -> Block -> [Block]
sectionToListItem opts (Div (ident,_,_)
(Header lev (_,classes,kvs) ils : subsecs))
| not (isNothing (lookup "number" kvs) && "unlisted" `elem` classes)
= Plain headerLink : [BulletList listContents | not (null listContents)
, lev < writerTOCDepth opts]
| lev <= writerTOCDepth opts
, not (isNothing (lookup "number" kvs) && "unlisted" `elem` classes)
= Plain headerLink : [BulletList listContents | not (null listContents)]
where
num = fromMaybe "" $ lookup "number" kvs
addNumber = if T.null num

15
test/command/5967.md Normal file
View file

@ -0,0 +1,15 @@
```
% pandoc --toc --toc-depth=3 -s -t plain
# One
## Two
#### Four
^D
- One
- Two
One
Two
Four
```