aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/extensions/toc.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py
index 1d9489c..fd2a86a 100644
--- a/markdown/extensions/toc.py
+++ b/markdown/extensions/toc.py
@@ -71,7 +71,10 @@ class TocTreeprocessor(markdown.treeprocessors.Treeprocessor):
else:
list_stack[-1].append(newlist)
list_stack.append(newlist)
- level += 1
+ if level == 0:
+ level = tag_level
+ else:
+ level += 1
# Do not override pre-existing ids
if not "id" in c.attrib: