Syntax Highlighting in Markdown with Pygments

If you want to get syntax highlighting using Pygments in Markdown texts, you have more or less 2 options. For one you can work on the HTML output of the Markdown2HTML converter of your choice, or you can try extending Markdown to offer special syntax for stuff you want to pass over to Pygments.

A good idea if you want to go the first route is the use of some kind of HTML parsing library like BeautifulSoup as shown in this snippet and this article.

This post will focus on the 2nd approach, though, since it is a bit cleaner :-)

Comment on this

You can use Markdown here.

Please answer the question in this field. It should help keeping spambots out ;-)