From 0b54d6282bb89a71433043857f4983668f9a4beb Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 7 Dec 2019 14:20:41 -0800 Subject: Fix --toc-depth regression in 2.8. Closes #5967. --- src/Text/Pandoc/Writers/Shared.hs | 6 +++--- test/command/5967.md | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 test/command/5967.md diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index 0161db506..6018b4294 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -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 diff --git a/test/command/5967.md b/test/command/5967.md new file mode 100644 index 000000000..9bb802d40 --- /dev/null +++ b/test/command/5967.md @@ -0,0 +1,15 @@ +``` +% pandoc --toc --toc-depth=3 -s -t plain +# One +## Two +#### Four +^D +- One + - Two + +One + +Two + +Four +``` -- cgit v1.2.3