diff options
author | Jannis Vajen <jvajen@gmail.com> | 2022-05-05 21:53:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 15:53:38 -0400 |
commit | 93d17b9cc4a3f53dc2059e44a691a28797422d21 (patch) | |
tree | 208bcc0ef29db5f4125bbaf2fa6ef7fd054c7ffe /markdown/extensions/toc.py | |
parent | efec51ac92059fc5b72f08832b481919a3ded6f3 (diff) | |
download | python-markdown-93d17b9cc4a3f53dc2059e44a691a28797422d21.tar.gz |
Support custom CSS class on TOC element
Closes #1224
Diffstat (limited to 'markdown/extensions/toc.py')
-rw-r--r-- | markdown/extensions/toc.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index 57d2e3b..80138b3 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -160,6 +160,7 @@ class TocTreeprocessor(Treeprocessor): self.base_level = int(config["baselevel"]) - 1 self.slugify = config["slugify"] self.sep = config["separator"] + self.toc_class = config["toc_class"] self.use_anchors = parseBoolValue(config["anchorlink"]) self.anchorlink_class = config["anchorlink_class"] self.use_permalinks = parseBoolValue(config["permalink"], False) @@ -239,7 +240,7 @@ class TocTreeprocessor(Treeprocessor): def build_toc_div(self, toc_list): """ Return a string div given a toc list. """ div = etree.Element("div") - div.attrib["class"] = "toc" + div.attrib["class"] = self.toc_class # Add title to the div if self.title: @@ -328,6 +329,9 @@ class TocExtension(Extension): "title": ["", "Title to insert into TOC <div> - " "Defaults to an empty string"], + "toc_class": ['toc', + 'CSS class(es) used for the link. ' + 'Defaults to "toclink"'], "anchorlink": [False, "True if header should be a self link - " "Defaults to False"], |