aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-10-27 12:22:23 -0700
committerJohn MacFarlane <[email protected]>2022-10-27 12:46:59 -0700
commit91436ebbf45d8d0891053ebdfbb837c71c4bf33a (patch)
tree233813aaf08647119c367a77a79310a893b594f5
parent87f4247d9e95ee545c0654fc06e6e295da360221 (diff)
T.P.Writers.Shared `toTableOfContents`: handle nested Divs better.
Closes #8402.
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs1
-rw-r--r--test/command/8402.md52
2 files changed, 53 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index 3fe643e63..2b109c65d 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -454,6 +454,7 @@ sectionToListItem opts (Div (ident,_,_)
then headerText'
else [Link ("toc-" <> ident, [], []) headerText' ("#" <> ident, "")]
listContents = filter (not . null) $ map (sectionToListItem opts) subsecs
+sectionToListItem opts (Div _ [d@Div{}]) = sectionToListItem opts d -- #8402
sectionToListItem _ _ = []
-- | Returns 'True' iff the list of blocks has a @'Plain'@ as its last
diff --git a/test/command/8402.md b/test/command/8402.md
new file mode 100644
index 000000000..67536227c
--- /dev/null
+++ b/test/command/8402.md
@@ -0,0 +1,52 @@
+```
+% pandoc --toc -s -t markdown
+::: {.cell .markdown id="6u8qXoeFGdqt"}
+# Summary
+> Expand to see summary
+
+## Overview and Explanation
+:::
+
+# Details
+
+## inner 1
+text
+
+## inner 2
+
+### inner inner 1
+
+## inner 3
+text
+^D
+- [Summary](#summary){#toc-summary}
+ - [Overview and
+ Explanation](#overview-and-explanation){#toc-overview-and-explanation}
+- [Details](#details){#toc-details}
+ - [inner 1](#inner-1){#toc-inner-1}
+ - [inner 2](#inner-2){#toc-inner-2}
+ - [inner inner 1](#inner-inner-1){#toc-inner-inner-1}
+ - [inner 3](#inner-3){#toc-inner-3}
+
+::: {#6u8qXoeFGdqt .cell .markdown}
+# Summary
+
+> Expand to see summary
+
+## Overview and Explanation
+:::
+
+# Details
+
+## inner 1
+
+text
+
+## inner 2
+
+### inner inner 1
+
+## inner 3
+
+text
+```