Mistletoe is a pure Python, CommonMark-compliant Markdown renderer that supports multiple backends such as HTML, Jira docs, and different flavors of Markdown. Because it parses the input into an abstract syntax tree (AST) before rendering, Mistletoe is highly extensible to new targets.
I implemented a new render backend for a common use-case, Limited HTML. By default, Markdown operates on a trusted input model and allows you to embed arbitrary HTML in your Markdown that will be passed through to the final render target, if possible. When using Markdown as a simple formatting language in e.g. website comments, it’s in the developer’s best interest to disallow such arbitrary formatting because it is a very common attack vector.
My Limited HTML render target is a modification of the full HTML renderer that simply escapes the content of any blocks parsed as inline HTML. I read the source code as well as the documents to identify the architecture and inserted my new code in an appropriate location. I use this functionality on a number of my other projects, including PCT Archive.