diff --git a/docs/extensions/toc.txt b/docs/extensions/toc.txt index 2cd1fa15f..742759028 100644 --- a/docs/extensions/toc.txt +++ b/docs/extensions/toc.txt @@ -124,4 +124,12 @@ The following options are provided to configure the output: The callable must return a string appropriate for use in HTML `id` attributes. * **`separator`**: - Word separator. Character which replaces white space in id. Defaults to "`-`". \ No newline at end of file + Word separator. Character which replaces white space in id. Defaults to "`-`". + +* **`toc_depth`** + Define up to which section level "n" (`
# we actually replace the
in its entirety. # We do not allow the marker inside a header as that - # would causes an enless loop of placing a new TOC + # would causes an endless loop of placing a new TOC # inside previously generated TOC. if c.text and c.text.strip() == self.marker and \ not self.header_rgx.match(c.tag) and c.tag not in ['pre', 'code']: @@ -233,6 +233,8 @@ def run(self, doc): for el in doc.iter(): if isinstance(el.tag, string_type) and self.header_rgx.match(el.tag): self.set_level(el) + if int(el.tag[-1]) > int(self.toc_depth): + continue text = ''.join(el.itertext()).strip() # Do not override pre-existing ids @@ -284,7 +286,10 @@ def __init__(self, *args, **kwargs): "slugify": [slugify, "Function to generate anchors based on header text - " "Defaults to the headerid ext's slugify function."], - 'separator': ['-', 'Word separator. Defaults to "-".'] + 'separator': ['-', 'Word separator. Defaults to "-".'], + "toc_depth": [6, + "Define up to which section level n (