mkdocs-enumerate-headings-plugin


Namemkdocs-enumerate-headings-plugin JSON
Version 0.6.2 PyPI version JSON
download
home_pagehttps://github.com/timvink/mkdocs-enumerate-headings-plugin.git
SummaryMkDocs Plugin to enumerate the headings (h1-h6) across site pages
upload_time2024-04-16 19:13:41
maintainerNone
docs_urlNone
authortimvink
requires_python>=3.7
licenseMIT
keywords mkdocs enumerate headings plugin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Actions Status](https://github.com/timvink/mkdocs-enumerate-headings-plugin/workflows/pytest/badge.svg)](https://github.com/timvink/mkdocs-enumerate-headings-plugin/actions)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mkdocs-enumerate-headings-plugin)
![PyPI](https://img.shields.io/pypi/v/mkdocs-enumerate-headings-plugin)
![PyPI - Downloads](https://img.shields.io/pypi/dm/mkdocs-enumerate-headings-plugin)
[![codecov](https://codecov.io/gh/timvink/mkdocs-enumerate-headings-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/timvink/mkdocs-enumerate-headings-plugin)
![GitHub contributors](https://img.shields.io/github/contributors/timvink/mkdocs-enumerate-headings-plugin)
![PyPI - License](https://img.shields.io/pypi/l/mkdocs-enumerate-headings-plugin)

# mkdocs-enumerate-headings-plugin

[MkDocs](https://www.mkdocs.org/) Plugin to enumerate the headings (h1-h6) across MkDocs pages.

> :point_right: If you're looking to add heading numbers to your site to support exporting to single-page standalone HTML or a PDF file, have a look at [mkdocs-print-site-plugin](https://timvink.github.io/mkdocs-print-site-plugin/) instead!

## Features :star2:

- Automatically number all headings and (optionally) give each page an sequential chapter number
- Great for writing (technical) reports
- Compatible with `plugins` like [awesome-pages](https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin) and [monorepo](https://github.com/spotify/mkdocs-monorepo-plugin)
- Compatible with `markdown_extensions` like [pymdownx.snippets](https://facelessuser.github.io/pymdown-extensions/extensions/snippets/)
- Compatible with themes like [mkdocs-material](https://github.com/squidfunk/mkdocs-material)
- Easy to customize styling through CSS

![demo screencast](demo_screencast.gif)

## Setup

Install the plugin using `pip`:

```bash
pip3 install mkdocs-enumerate-headings-plugin
```

Next, add the following lines to your `mkdocs.yml`:

```yml
plugins:
  - search
  - enumerate-headings
```

> MkDocs executes plugins in the order they are defined. If you use any other plugins that alter the navigation, make sure to define them *before* the `enumerate-headings` plugin.

> If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set.

## Usage

`enumerate-headings` will increment the chapter number for each new page (in the order they appear in the navigation) and enumerate all subheadings (unless you disable in this in the options).

There is only one requirement: make sure each markdown page starts with a level 1 header (see [how to write markdown headers](https://daringfireball.net/projects/markdown/syntax#header)). Some MkDocs themes will handle this for your automatically, inserting the page title as a heading 1 if you do not specify one. If a heading 1 is still missing, you'll get a helpful error.

Pages with multiple level 1 headings are allowed and the chapter numbers will increment accordingly.

> Note this plugin does not affect your markdown files, only the rendered HTML.

### Styling

All heading numbers are wrapped in `<span class='enumerate-headings-plugins'></span>` and can be styled using CSS. See [customizing a MkDocs theme](https://www.mkdocs.org/user-guide/styling-your-docs/#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](https://www.mkdocs.org/user-guide/configuration/#extra_css) setting in your `mkdocs.yml` file.

```css
/* Extra CSS for mkdocs-enumerate-headings-plugin */ 
.enumerate-headings-plugin {
  filter: opacity(35%);
}
```

## Options

You can customize the plugin by setting options in `mkdocs.yml`:

```yml
plugins:
    - enumerate-headings:
        toc_depth: 0
        strict: true
        increment_across_pages: true
        include:
          - "*"
        exclude:
          - index.md
          - another_page.md
        restart_increment_after:
          - second_section.md
```

- **`toc_depth`** (default `0`): 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. Max is 6 (showing all enumeration)
- **`strict`** (default `true`): Raise errors instead of warnings when first heading on a page is not a level one heading (single `#`) and your MkDocs theme has not inserted the page title as a heading 1 for you. Note that in `strict: false` mode the heading numbers might be incorrect between pages and before and after a level 1 heading.
- **`increment_across_pages`** (default `true`): Increment the chapter number for each new page (in the order they appear in the navigation). If disabled, each page will start from 1.
- **`include`** (default *`["*"]`*): Specify a list of page source paths (one per line) that should have enumeration (included in processing by this plugin). This can be useful for example to include enumeration on only one directory. The source path of a page is relative to your `docs/` folder. You can also use [globs](https://docs.python.org/3/library/glob.html) instead of source paths. For example, to include `docs/subfolder/page.md` specify in your `mkdocs.yml` a line under `include:` with `- subfolder/page.md`
- **`exclude`** (default *not specified*): Specify a list of page source paths (one per line) that should not have enumeration (excluded from processing by this plugin). This can be useful for example to remove enumeration from the front page. The source path of a page is relative to your `docs/` folder. You can also use [globs](https://docs.python.org/3/library/glob.html) instead of source paths. For example, to exclude `docs/subfolder/page.md` specify in your `mkdocs.yml` a line under `exclude:` with `- subfolder/page.md`
- **`restart_increment_after`** (default *not specified*): Specify a list of page source paths (one per line) where enumeration should be restarted. This can be useful if you have multiple reports or tutorials in one mkdocs site. Paths behave as with `exclude` (can use globs).

## Contributing

Contributions are very welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before putting in any work.

Credits: This plugin was inspired by [ignorantshr/mkdocs-add-number-plugin](https://github.com/ignorantshr/mkdocs-add-number-plugin), which focuses on enumerating single selected pages.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/timvink/mkdocs-enumerate-headings-plugin.git",
    "name": "mkdocs-enumerate-headings-plugin",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "mkdocs enumerate headings plugin",
    "author": "timvink",
    "author_email": "vinktim@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/80/ee/cc24e435b543c2a974e8cbd91e69ead661799b4f3d7174801b104f3be251/mkdocs_enumerate_headings_plugin-0.6.2.tar.gz",
    "platform": null,
    "description": "[![Actions Status](https://github.com/timvink/mkdocs-enumerate-headings-plugin/workflows/pytest/badge.svg)](https://github.com/timvink/mkdocs-enumerate-headings-plugin/actions)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mkdocs-enumerate-headings-plugin)\n![PyPI](https://img.shields.io/pypi/v/mkdocs-enumerate-headings-plugin)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/mkdocs-enumerate-headings-plugin)\n[![codecov](https://codecov.io/gh/timvink/mkdocs-enumerate-headings-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/timvink/mkdocs-enumerate-headings-plugin)\n![GitHub contributors](https://img.shields.io/github/contributors/timvink/mkdocs-enumerate-headings-plugin)\n![PyPI - License](https://img.shields.io/pypi/l/mkdocs-enumerate-headings-plugin)\n\n# mkdocs-enumerate-headings-plugin\n\n[MkDocs](https://www.mkdocs.org/) Plugin to enumerate the headings (h1-h6) across MkDocs pages.\n\n> :point_right: If you're looking to add heading numbers to your site to support exporting to single-page standalone HTML or a PDF file, have a look at [mkdocs-print-site-plugin](https://timvink.github.io/mkdocs-print-site-plugin/) instead!\n\n## Features :star2:\n\n- Automatically number all headings and (optionally) give each page an sequential chapter number\n- Great for writing (technical) reports\n- Compatible with `plugins` like [awesome-pages](https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin) and [monorepo](https://github.com/spotify/mkdocs-monorepo-plugin)\n- Compatible with `markdown_extensions` like [pymdownx.snippets](https://facelessuser.github.io/pymdown-extensions/extensions/snippets/)\n- Compatible with themes like [mkdocs-material](https://github.com/squidfunk/mkdocs-material)\n- Easy to customize styling through CSS\n\n![demo screencast](demo_screencast.gif)\n\n## Setup\n\nInstall the plugin using `pip`:\n\n```bash\npip3 install mkdocs-enumerate-headings-plugin\n```\n\nNext, add the following lines to your `mkdocs.yml`:\n\n```yml\nplugins:\n  - search\n  - enumerate-headings\n```\n\n> MkDocs executes plugins in the order they are defined. If you use any other plugins that alter the navigation, make sure to define them *before* the `enumerate-headings` plugin.\n\n> If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set.\n\n## Usage\n\n`enumerate-headings` will increment the chapter number for each new page (in the order they appear in the navigation) and enumerate all subheadings (unless you disable in this in the options).\n\nThere is only one requirement: make sure each markdown page starts with a level 1 header (see [how to write markdown headers](https://daringfireball.net/projects/markdown/syntax#header)). Some MkDocs themes will handle this for your automatically, inserting the page title as a heading 1 if you do not specify one. If a heading 1 is still missing, you'll get a helpful error.\n\nPages with multiple level 1 headings are allowed and the chapter numbers will increment accordingly.\n\n> Note this plugin does not affect your markdown files, only the rendered HTML.\n\n### Styling\n\nAll heading numbers are wrapped in `<span class='enumerate-headings-plugins'></span>` and can be styled using CSS. See [customizing a MkDocs theme](https://www.mkdocs.org/user-guide/styling-your-docs/#customizing-a-theme) on how to add an CSS to your theme.\n\nAs 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](https://www.mkdocs.org/user-guide/configuration/#extra_css) setting in your `mkdocs.yml` file.\n\n```css\n/* Extra CSS for mkdocs-enumerate-headings-plugin */ \n.enumerate-headings-plugin {\n  filter: opacity(35%);\n}\n```\n\n## Options\n\nYou can customize the plugin by setting options in `mkdocs.yml`:\n\n```yml\nplugins:\n    - enumerate-headings:\n        toc_depth: 0\n        strict: true\n        increment_across_pages: true\n        include:\n          - \"*\"\n        exclude:\n          - index.md\n          - another_page.md\n        restart_increment_after:\n          - second_section.md\n```\n\n- **`toc_depth`** (default `0`): 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. Max is 6 (showing all enumeration)\n- **`strict`** (default `true`): Raise errors instead of warnings when first heading on a page is not a level one heading (single `#`) and your MkDocs theme has not inserted the page title as a heading 1 for you. Note that in `strict: false` mode the heading numbers might be incorrect between pages and before and after a level 1 heading.\n- **`increment_across_pages`** (default `true`): Increment the chapter number for each new page (in the order they appear in the navigation). If disabled, each page will start from 1.\n- **`include`** (default *`[\"*\"]`*): Specify a list of page source paths (one per line) that should have enumeration (included in processing by this plugin). This can be useful for example to include enumeration on only one directory. The source path of a page is relative to your `docs/` folder. You can also use [globs](https://docs.python.org/3/library/glob.html) instead of source paths. For example, to include `docs/subfolder/page.md` specify in your `mkdocs.yml` a line under `include:` with `- subfolder/page.md`\n- **`exclude`** (default *not specified*): Specify a list of page source paths (one per line) that should not have enumeration (excluded from processing by this plugin). This can be useful for example to remove enumeration from the front page. The source path of a page is relative to your `docs/` folder. You can also use [globs](https://docs.python.org/3/library/glob.html) instead of source paths. For example, to exclude `docs/subfolder/page.md` specify in your `mkdocs.yml` a line under `exclude:` with `- subfolder/page.md`\n- **`restart_increment_after`** (default *not specified*): Specify a list of page source paths (one per line) where enumeration should be restarted. This can be useful if you have multiple reports or tutorials in one mkdocs site. Paths behave as with `exclude` (can use globs).\n\n## Contributing\n\nContributions are very welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before putting in any work.\n\nCredits: This plugin was inspired by [ignorantshr/mkdocs-add-number-plugin](https://github.com/ignorantshr/mkdocs-add-number-plugin), which focuses on enumerating single selected pages.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "MkDocs Plugin to enumerate the headings (h1-h6) across site pages",
    "version": "0.6.2",
    "project_urls": {
        "Homepage": "https://github.com/timvink/mkdocs-enumerate-headings-plugin.git"
    },
    "split_keywords": [
        "mkdocs",
        "enumerate",
        "headings",
        "plugin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6cde3c1a764e1db8991ed33c8cedc52d4a6b9b1b857b20ea3e625d0d7a2594ef",
                "md5": "c48677d9f6205df22507fe6f5182abbb",
                "sha256": "6bec6674091509290e1f24a0c9272b887c5242e8af6fbddb8eb2b089f52d5bfe"
            },
            "downloads": -1,
            "filename": "mkdocs_enumerate_headings_plugin-0.6.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c48677d9f6205df22507fe6f5182abbb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 11332,
            "upload_time": "2024-04-16T19:13:40",
            "upload_time_iso_8601": "2024-04-16T19:13:40.093769Z",
            "url": "https://files.pythonhosted.org/packages/6c/de/3c1a764e1db8991ed33c8cedc52d4a6b9b1b857b20ea3e625d0d7a2594ef/mkdocs_enumerate_headings_plugin-0.6.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "80eecc24e435b543c2a974e8cbd91e69ead661799b4f3d7174801b104f3be251",
                "md5": "2401b99ada8ff119ebccc44468912458",
                "sha256": "392782dbbbb9f7f62af852b6f2724ae515043dbb7397cd68dd62f134dd1b3ab5"
            },
            "downloads": -1,
            "filename": "mkdocs_enumerate_headings_plugin-0.6.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2401b99ada8ff119ebccc44468912458",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 14938,
            "upload_time": "2024-04-16T19:13:41",
            "upload_time_iso_8601": "2024-04-16T19:13:41.750343Z",
            "url": "https://files.pythonhosted.org/packages/80/ee/cc24e435b543c2a974e8cbd91e69ead661799b4f3d7174801b104f3be251/mkdocs_enumerate_headings_plugin-0.6.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-16 19:13:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "timvink",
    "github_project": "mkdocs-enumerate-headings-plugin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mkdocs-enumerate-headings-plugin"
}
        
Elapsed time: 0.31249s