Skip to content

Commit c016844

Browse files
committed
Typos
1 parent b434317 commit c016844

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

docs/extensions/toc.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,25 @@ The following options are provided to configure the output:
239239
Word separator. Character which replaces white space in id. Defaults to "`-`".
240240

241241
* **`toc_depth`**
242+
Define the range of section levels to include in the Table of Contents.
243+
A single integer (`b`) defines the bottom section level (`<h1>..<hb>`) only.
244+
A string consisting of two digits separated by a hyphen in between (`"2-5"`),
245+
define the top (`t`) and the bottom (`b`) (`<ht>..<hb>`). Defaults to `6` (bottom).
246+
247+
When used with conjunction with `baselevel`, this parameter will not
248+
take the fitted hierarchy from `baselevel` into account. That is, if
249+
both `toc_depth` and `baselevel` are `3`, then only the highest level
250+
will be present in the table. If you set `baselevel` to `3` and
251+
`toc_depth` to `"2-6"`, the *first* headline will be `<h3>` and so still
252+
included in the Table of Contents. To exclude this first level, you
253+
have to set `toc_depth` to `"4-6"`.
254+
255+
* **`max_level`**
242256
Define the highest heading level (deepest `<hN>`) for which to add anchor links or permalinks.
243-
Defaults to `6`
257+
Defaults to `6`.
244258

245259
For example, setting max_level to `2` adds anchors only to `<h1>` and `<h2>` elements.
246260

247-
* **`max_level`**
248-
249261
A trivial example:
250262

251263
```python

markdown/extensions/toc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def __init__(self, md: Markdown, config: dict[str, Any]):
257257
self.permalink_class: str = config["permalink_class"]
258258
self.permalink_title: str = config["permalink_title"]
259259
self.permalink_leading: bool | None = parseBoolValue(config["permalink_leading"], False)
260-
self.header_rgx = re.compile(f'[Hh][1-{config["max_level"]}')
260+
self.header_rgx = re.compile(f'[Hh][1-{config["max_level"]}]')
261261
if isinstance(config["toc_depth"], str) and '-' in config["toc_depth"]:
262262
self.toc_top, self.toc_bottom = [int(x) for x in config["toc_depth"].split('-')]
263263
else:

0 commit comments

Comments
 (0)