Skip to main content

A Python-Markdown extension to downgrade headings

Project description

Headdown: Downgrade Headings

Automatically demote those pesky headings!

What?

This is a plugin for Python-Markdown to automatically downgrade headings by a given number of levels. This is useful when, for example, using a static site generator, such as Pelican.

Why?

I didn't want to have to write standalone markdown files whose structure was dictated by the constraints of my website; nor did I want to sacrifice the structure of my website because of my markdown files. A number of 3rd party Python-Markdown extensions already exist to do this (here and here), but I was unable to get them to work with Python-Markdown 3.

How?

Just add mdx_headdown to your markdown extensions and feel the magic.

You can optionally provide an offset parameter, which tells headdown by how many levels to downgrade all headings. The default is 1.

Note : This value will be converted to an integer and absolutised. Failure to provide a numeric option may lead to unexpected results.

For example, if using with Pelican, your configuration might look something like this:

...
MARKDOWN = {
    'extensions': ['mdx_headdown',],
    'extension_configs': {
        'mdx_headdown': {
            'offset': 2,
        },
    },
}
...

Credit

Thanks are owed to the author of mdx_downheader, whose code I examined for inspiration; and the contributers to the default python-markdown extensions, whose code I examined to get a better idea of what the manual was talking about.

This project is copyright 2018 by Sascha Cowley under the MIT License.

Project details


Download files

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

Source Distribution

markdown-headdown-0.1.3.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markdown_headdown-0.1.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file markdown-headdown-0.1.3.tar.gz.

File metadata

  • Download URL: markdown-headdown-0.1.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for markdown-headdown-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ced7f86b3014297e0d20306744f01911a3da3ff01ad014900f22c250d5e07dec
MD5 6a1e7e431c6c237013ec78141e0949fa
BLAKE2b-256 7ad0ddaeb580e9d6a5327511e35de23fc23439a9de8fa920dff50fb60e2da1e3

See more details on using hashes here.

File details

Details for the file markdown_headdown-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: markdown_headdown-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for markdown_headdown-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 30d819d719e53e9b06d060b30fda2cb5753a76a762de279eedbd638840733c82
MD5 d24ef83f314f644d522c9d1f767cd5b9
BLAKE2b-256 61f42766f7219c96f124b7ea53e6cae8090f325a7525212b51b5d9aa4b9b7caa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page