MkDocs Plugin to enumerate the headings (h1-h6) across site pages
Project description
mkdocs-enumerate-headings-plugin
MkDocs Plugin to enumerate the headings (h1-h6) across site pages
Features :star2:
- Automatically number all headings and give each page an sequential chapter number
- Compatible with
plugins
like awesome-pages and monorepo - Compatible with
markdown_extensions
like 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 (see how to write markdown headers). Pages with no headings and pages with multiple level 1 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 styled using CSS. See MkDocs documentation for customizing a theme on how to add an CSS to your theme.
As an example you can make the numbering lighter than the heading title by saving the CSS snippet below to a file and adding it to your MkDocs site using the extra_css setting in your mkdocs.yml
file.
/* 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
toc_depth: 0
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.toc_depth
(default0
): Up to which level the table of contents should be enumerated as well. Default is 0, which means the TOC is not enumerated at all.
Contributing
Contributions are very welcome! 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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31a5216ee6234765cd9100ea32ceb48946b2d2cc0ec2b5d1f1ed3589940d70a9 |
|
MD5 | 7c3456c512a7ee1ded288c2030c56d76 |
|
BLAKE2b-256 | d33e84e818a2230d2f66ea0f0fa411add349e420d2af5650bd2323d5f06103f1 |
Hashes for mkdocs_enumerate_headings_plugin-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd9fc30a35457fc9edde8475bf1ed02f8a0776e191fe2e2ceca4e9e42fc7f3f6 |
|
MD5 | 65b2155a1ac7566226943c7dc58476ee |
|
BLAKE2b-256 | 7fa5825a21c76c43ca25c3a1aad618c77e542d40ffe5419e31e37112e545ce7f |