Skip to content

Commit

Permalink
Some cleanup on toc tag, refs simonw#145
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jul 2, 2023
1 parent 5b4f635 commit 76396c1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions plugins/toc_template_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ def build_tree(links):


def tree_to_html(tree):
html = "<ul>\n"
for depth, name, link, children in tree:
html += f' <li><a href="#{link}">{name}</a>'
html = ["<ul>"]
for _, name, link, children in tree:
html.append(f' <li><a href="#{link}">{name}</a>')
if children:
html += "\n" + tree_to_html(children) + " "
html += "</li>\n"
html += "</ul>"
return html
html.append(tree_to_html(children))
html.append("</li>")
html.append("</ul>")
return "\n".join(html)

0 comments on commit 76396c1

Please sign in to comment.