FSX / misaka

A Python binding for Hoedown.
http://misaka.61924.nl
MIT License
418 stars 65 forks source link

Customize HtmlTocRenderer anchor link #63

Closed ghost closed 5 years ago

ghost commented 7 years ago

Hello

I am trying to customize the output of the HtmlTocRenderer

I wish to replace this output:

<ul>
    <li><a href="#toc_0">My article</a> </li>
</ul>

By this one:

<ul>
    <li><a href="#my-article">My article</a> </li>
</ul>

It is possible to do this by inheriting HtmlTocRenderer, or have to write another function for that ?

FSX commented 5 years ago

Yes, you if you set the header-callback in the renderer.

See: http://misaka.61924.nl/#misaka.BaseRenderer.header