Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/change_log/release-3.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ The following new features have been included in the release:

* Add support for Python 3.8.

* A new `permalink_title` parameter has been added to the
[Table of Contents Extension](../extensions/toc.md).

## Bug fixes

The following bug fixes are included in the 3.2 release:
Expand Down
3 changes: 3 additions & 0 deletions docs/extensions/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ The following options are provided to configure the output:
the link text. When set to a string, the provided string is used as the link
text.

* **`permalink_title`**:
Title attribute of the permanent link. Defaults to `Permanent link`.

* **`baselevel`**:
Base level for headers. Defaults to `1`.

Expand Down
7 changes: 6 additions & 1 deletion markdown/extensions/toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, md, config):
self.use_permalinks = parseBoolValue(config["permalink"], False)
if self.use_permalinks is None:
self.use_permalinks = config["permalink"]
self.permalink_title = config["permalink_title"]
self.header_rgx = re.compile("[Hh][123456]")
if isinstance(config["toc_depth"], str) and '-' in config["toc_depth"]:
self.toc_top, self.toc_bottom = [int(x) for x in config["toc_depth"].split('-')]
Expand Down Expand Up @@ -192,7 +193,8 @@ def add_permalink(self, c, elem_id):
else self.use_permalinks)
permalink.attrib["href"] = "#" + elem_id
permalink.attrib["class"] = "headerlink"
permalink.attrib["title"] = "Permanent link"
if self.permalink_title:
permalink.attrib["title"] = self.permalink_title
c.append(permalink)

def build_toc_div(self, toc_list):
Expand Down Expand Up @@ -291,6 +293,9 @@ def __init__(self, **kwargs):
"permalink": [0,
"True or link text if a Sphinx-style permalink should "
"be added - Defaults to False"],
"permalink_title": ["Permanent link",
"Title attribute of the permalink - "
"Defaults to 'Permanent link'"],
"baselevel": ['1', 'Base level for headers.'],
"slugify": [slugify,
"Function to generate anchors based on header text - "
Expand Down