M src/wiki/conf/settings.py => src/wiki/conf/settings.py +3 -0
@@ 60,6 60,9 @@ MARKDOWN_KWARGS = {
'markdown.extensions.abbr',
'markdown.extensions.sane_lists',
],
+ 'extension_configs': {
+ 'wiki.plugins.macros.mdx.toc': {'title': _('Table of Contents')},
+ },
}
MARKDOWN_KWARGS.update(getattr(django_settings, 'WIKI_MARKDOWN_KWARGS', {}))
M src/wiki/plugins/macros/mdx/toc.py => src/wiki/plugins/macros/mdx/toc.py +4 -20
@@ 15,26 15,10 @@ def wiki_slugify(*args, **kwargs):
class WikiTreeProcessorClass(TocTreeprocessor):
- def build_toc_etree(self, div, toc_list):
- # Add title to the div
- if self.config["title"]:
- header = etree.SubElement(div, "span")
- header.attrib["class"] = "toctitle"
- header.text = self.config["title"]
-
- def build_etree_ul(toc_list, parent):
- ul = etree.SubElement(parent, "ul")
- for item in toc_list:
- # List item link, to be inserted into the toc div
- li = etree.SubElement(ul, "li")
- link = etree.SubElement(li, "a")
- link.text = item.get('name', '')
- link.attrib["href"] = '#' + item.get('id', '')
- if item['children']:
- build_etree_ul(item['children'], li)
- return ul
-
- return build_etree_ul(toc_list, div)
+ def run(self, doc):
+ if self.title:
+ self.title = str(self.title)
+ super().run(doc)
class WikiTocExtension(TocExtension):