Skip to content

fancsali/mdx_downheader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

Python Markdown Down Header Extension

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%