Mistletoe: a fast, extensible CommonMark implementation in pure Python

I’ve personally wanted a CommonMark-conformant parser implementation in pure Python for a while. python-markdown and mistune, for example, both supports Gruber’s specification, but not CommonMark. There is, more recently, CommonMark-py, which is a direct port of commonmark.js.

mistletoe, the project I have been working on for almost a year now, is a Markdown parser implementation in pure, native Python. In addition to conforming to the latest verion of the spec (0.28), it:

  • runs 2 to 3 times faster than CommonMark-py, and marginally faster than python-markdown. Running with PyPy yields comparable performance with mistune.

  • has well-defined extension rules, and supports strikethrough and tables out of the box. Its design is flexible enough that you can write a Lisp in it.

  • supports alternative output format, including dumping an abstract syntax tree or emitting LaTeX.

Working with a clear, readable specification is a pleasure and a learning experience. I had immense fun designing and implementing mistletoe, and I hope it can help others as much as it helped me.