miyuchina / mistletoe

A fast, extensible and spec-compliant Markdown parser in pure Python.
MIT License
841 stars 119 forks source link

Is there a way to set allowed tags to parse? #116

Closed gxfr closed 3 years ago

gxfr commented 3 years ago

Suppose I would only like to parse italics, bold and headers. Is there a way to only parse <i>, <b> and <h1-6> tags?

pbodnar commented 3 years ago

Hi there, I don't think there's an easy / general way to say that just some Markdown constructs should be parsed. Fortunately though, this won't be needed by many mistletoe users, I guess?

Insight: While custom renderers can add their own extra tokens to be parsed, the default set of parsed tokens is pretty much hard-coded. There is also this core_tokens.py which takes care of parsing all the "core" tokens like emphasis, italics, links (including footnotes) or images "in one go", without the possibility to easily skip some of them.

I hope I answered your question. :)