misaka icon indicating copy to clipboard operation
misaka copied to clipboard

No ids for headers

Open geekyogurt opened this issue 6 years ago • 4 comments

Flask Misaka, unlike jekyll and python markdown library doesnot add id to headings.

geekyogurt avatar Sep 20 '19 10:09 geekyogurt

How are you using Misaka? Do you have a code snippet?

To include IDs you can pass nesting_level to HtmlRenderer. See: https://misaka.61924.nl/#misaka.HtmlRenderer

It's not a very friendly API now that I look at it.

FSX avatar Sep 20 '19 11:09 FSX

I am using Flask-Misaka.https://github.com/singingwolfboy/flask-misaka {{data|markdown}} in html and initializing the app using: Misaka(app, fenced_code=True, tables=True, footnotes=True, toc=True,space_headers=True)

geekyogurt avatar Sep 20 '19 12:09 geekyogurt

@geekyogurt Sorry, I was busy. I'll reply with an answer to your question tonight.

FSX avatar Sep 24 '19 16:09 FSX

I'm guessing the following should work:

import misaka
Misaka(
    app,
    fenced_code=True,
    tables=True,
    footnotes=True,
    space_headers=True,
    renderer=HtmlRenderer(nesting_level=6),
)

I don't see a way to add a table of contents renderer into the current Flask-Misaka code. toc=True also isn't an argument I see in Flask-Misaka's code.

I'm guessing the HtmlRenderer class should be extended to generate a table of contents or Flask-Misaka extend's it API to add more than one template filter.

FSX avatar Sep 24 '19 18:09 FSX