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.
Permalink
Failed to load latest commit information.
tests
.gitignore
.travis.yml
Readme.md
mdx_downheader.py
requirements.txt
setup.cfg
setup.py

Readme.md

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>

Easy!

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

Usage

Directly from python

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

From the command line

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

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 pelicanconf.py 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!