Skip to main content

Create table of contents for markdown files

Project description

markdown-toc-creator

This is a command-line tool to create table of contents from markdown files.

1. Installation

pip install markdown-toc-creator

2. Usage

In the markdown files that you would like to generate tables of contents, put this placeholder at where you would like to the table of contents to go:

<!--TOC-->

<!--TOC-->

And then run this command:

markdown-toc-creator <PATH_TO_FOLDER_OR_FILE>

A table of contents will be put between <!--TOC-->.

Or, to use it as a pre-commit hook, add this into your .pre-commit-config.yaml file:

  - repo: https://github.com/jsh9/markdown-toc-creator
    rev: <REPLACE_WITH_LATEST_VERSION>
    hooks:
      - id: markdown-toc-creator

3. Configuration options

3.1. --style

Pick between "gitlab" or "github" (default).

3.2. --exclude

Regex of file/folder name patterns to exclude, default: '\.git|\.tox|\.pytest_cache'

3.3. --in-place

Whether to actually add the table of contents into the original markdown file. Default: True.

3.4. --quiet (or -q)

If True, the generated table of contents will not be printed to the terminal. Default: False.

3.5. --skip-first-n-lines

How many lines of the markdown file (starting from the top) to skip. This is useful because usually the initial line of markdown file is H1 (header level 1, with a #), and we don't want it to be included in the table of content.

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_toc_creator-0.0.7.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

markdown_toc_creator-0.0.7-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file markdown_toc_creator-0.0.7.tar.gz.

File metadata

  • Download URL: markdown_toc_creator-0.0.7.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for markdown_toc_creator-0.0.7.tar.gz
Algorithm Hash digest
SHA256 dd37cff2cb2ab5e102bb6defa1b8b69f3960adc48f57d2d94833743a11520ccd
MD5 b50dd2c79b046cd308973a26378fa033
BLAKE2b-256 e8d75875e5ae38c85b4bcf1d3a155854d5c604fe10cd33c7b35aaab63ad7ed3f

See more details on using hashes here.

File details

Details for the file markdown_toc_creator-0.0.7-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for markdown_toc_creator-0.0.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e893ce3440f1656af22be5e2673fb89a6d927e2d137e2f5ca705cb4794437479
MD5 521a4c21f6ca6f65d344d8f3b2db86f8
BLAKE2b-256 3af41a76f40efdef936252db7a891f0483077d8ecc2120bb76ba08ddaa3cef66

See more details on using hashes here.

Supported by

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