MkDocs Plugin to enumerate the headings (h1-h6) in a MkDocs site
Project description
mkdocs-enumerate-headings-plugin
MkDocs Plugin to enumerate the headings (h1-h6) in a MkDocs site
Features :star2:
- Automatically numbers all headings and gives each page an sequential chapter number
- Compatible with
plugins
like awesome-pages and monorepo - Compatible with
markdown_extensions
: pymdownx.snippets - Easy to customize styling through CSS
Setup
Install the plugin using pip
:
pip3 install mkdocs-enumerate-headings-plugin
Next, add the following lines to your mkdocs.yml
:
plugins:
- search
- enumerate-headings
If you have no
plugins
entry in your config file yet, you'll likely also want to add thesearch
plugin. MkDocs enables it by default if there is noplugins
entry set.
Usage
There is only one requirement: make sure each markdown page starts with a level 1 header (#
).
Pages with no headings and pages with multiple h1 headings are allowed.
Note this plugin only affects your rendered HTML and does not affect the markdown files.
Styling
All heading numbers are wrapped in <span class='enumerate-headings-plugins'></span>
and can be customized using CSS. See MkDocs documentation for customizing a theme on how to add an CSS to your theme.
As a suggestion here is some CSS that makes the numbers slightly lighter than the heading:
/* Extra CSS for mkdocs-enumerate-headings-plugin */
.enumerate-headings-plugins {
/* 100% is baseline so 250% is a lot lighter */
filter: brightness(250%);
}
Options
You can customize the plugin by setting options in mkdocs.yml
:
plugins:
- enumerate-headings:
strict: true
strict
(defaulttrue
): Raise errors instead of warnings when first heading on a page is not a level one heading (single#
). Note that instrict: false
mode the heading numbers might be incorrect between pages and before and after a level 1 heading.
Contributing
Very much open to contributions! Please read CONTRIBUTING.md before putting in any work.
This plugin was inspired by ignorantshr/mkdocs-add-number-plugin, which focuses on enumerating single selected pages.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mkdocs-enumerate-headings-plugin-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02c0aee35448b86e058c690c2a9faf2305b34d68c7bb8fea61bf567d9b04eece |
|
MD5 | 13df52d8b645f06eb21ddbf27614349c |
|
BLAKE2b-256 | c9d01ce2eb5d624473a585d7feebd896d481567651ef1a37039778a9e3f8f4d2 |
Hashes for mkdocs_enumerate_headings_plugin-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38deac774191fb878aefd6798bd29c6c1c03c2a5bb2fe5da5951ad453bc8f755 |
|
MD5 | b272362eb8bc5970c6eb6694384aa699 |
|
BLAKE2b-256 | a5e8dd5d9953b9f4afff1c2b58309569475c93a7996df7cc6f1afda4161c28cd |