Python Markdown Down Header Extension
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Header Downgrader Extension for Python Markdown.

Build status Coverage PyPI version

When working with markdown files, sometimes you need to "downgrade" your headings for styling purposes. A good case scenario for this is using markdown with static site generators, for example, Pelican.

Given a piece of markdown like this:

# This is header 1
## This is header 2

Python Markdown will generate the following HTML:

<h1>This is header 1</h1>
<h2>This is header 2</h2>

With this extension enabled we obtain this instead:

<h2>This is header 1</h2>
<h3>This is header 2</h3>


How to install

Tested with Python 2.7 and Python 3.5

It requires the awesome Python Markdown package, tested with Markdown 2.6.5


Directly from python

from markdown import markdown
text = '# hello world'
markdown(text, ['downheader(levels=1)',]

From the command line

echo '# hello world' >
python -m markdown -o html5 -x 'downheader(levels=1)' -f test.html

Note: Some static site generators, like Pelican, can use markdown extensions. You just need to install the pip package and provide the name of the markdown extension (in this case the name is simply 'downheader'). For example, for Pelican just add this to your file:

MD_EXTENSIONS = ['downheader']

Errors? bugs?

Simple, just create a ticket in Github, this will help me to maintain the library.

Contributions? pull requests?

This is github, just fork and create a pull request, you will be always welcome to contribute!