However, i'm curious, is this repo still maintained, and if yes, can you add an option to turn the generated 'table of content' into a html one? So it can become a dropwdown list like this:
i use this code to manually turn the generated TOC from your extension into the html one. (it's not perfect, it also has flaws, since I'm a noob, but i hope you got my point)
intro = """
<details>
<summary>Table of Contents</summary>
<ol>
"""
outro = """
</li>
</ol>
</details>
"""
tableofcontents = """
- [Installation](#installation)
- [About](#about)
- [Example](#example)
- [Syntax](#syntax)
- [Valid Hashtags](#valid-hashtags)
"""
def mlineprint(toprint):
if toprint[-1] == '\n':
toprint = toprint[:-1]
print(toprint.replace('\n', '', 1))
def writehtmllist(space, namehead, hashtaghead):
spaces = ""
for _ in range(space):
spaces += " "
if initialspace >= 2:
return spaces + f'<ul><li><a href="{hashtaghead}">{namehead}</a></li></ul>'
else:
return spaces + f'<li><a href="{hashtaghead}">{namehead}</a></li>'
if __name__ == "__main__":
rows = tableofcontents.replace('\n', '', 1).splitlines()#split('\n') # split into a list of rows
mlineprint(intro)
for row in rows:
if not row == '':
initialspace = 0
for char in row:
if char == ' ':
initialspace += 1
else:
break
extractedrow = row.split("[")
cuttedrow = extractedrow[1].partition("](")
headingname = cuttedrow[0]
headinghashtag = cuttedrow[2].rstrip(")")
print(writehtmllist(initialspace+4, headingname, headinghashtag))
mlineprint(outro)
That's from me. I don't know if it's possible (i mean easy to implement) or not, and if you don't want to implement it, that's totally okay!