Skip to main content

Generate html from markdown with code-block highlighting

Project description

Build Status Coverage Status


A stupid simple bit of code which combines mistune and pygments to convert markdown into html. Very similar to github markdown, but for python.


pip install markdown-code-blocks


The library provides a single function highlight which takes in a markdown string and returns html.

You can also use the cli markdown-code-blocks-highlight. It optionally takes a single filename (defaulting to stdin) and writes to stdout.

For example:

markdown-code-blocks-highlight > f.htm

pygments css

I'd suggest grabbing a theme file from pygments-css (or any other provider of pygments themes -- if you google there's a bunch of them).

This library will use the class .highlight so be sure to change out whatever class the theme uses with that.

Most themes (for whatever reason) don't add styles for diff display. I usually do something like this:

.highlight .gi { color: #070; }
.highlight .gd { color: #911; }

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
markdown_code_blocks-1.4.0-py2.py3-none-any.whl (3.8 kB) Copy SHA256 hash SHA256 Wheel py2.py3
markdown_code_blocks-1.4.0.tar.gz (3.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page