Skip to main content

Markdown Contents Generator

Generate table of contents for markdown files.

Installation

Install via PIP

Install via python pip (python3 required):

pip install markdown-contents-generator --user

Install from Source

Clone git-repository and make setup inside the project directory:

git clone https://github.com/fadich/markdown-contents-generator.git \
  && cd markdown-contents-generator

python3 setup.py install

Usage

Once the package installed, it provides a console command:

md-contents-generator

You can call it with no arguments to view the instructions. The only required parameter is a path to the markdown file which table of contents you're going to generate.

Generate Table of Contents

By proving MARKDOWN_FILEPATH positional parameter, you can generate its contents and check the console output results. For example:

md-contents-generator README.md

You will see something like that (for this README.md file):

- [Usage](#usage)
  - [Generate Table of Contents](#generate-table-of-contents)
  - [Insert Table of Contents into a File](#insert-table-of-contents-into-a-file)
    - [Replace Contents Tags](#replace-contents-tags)
- [Installation](#installation)
  - [Install via PIP](#install-via-pip)
  - [Install from Source](#install-from-source)

You can copy-paste it to the file you need or make auto-insertion to your working file (see below).

Insert Table of Contents into a File

Command can be called with optional --insert flag:

md-contents-generator README.md --insert

This will automatically insert auto-generated contents inside the contents tags. So, before calling this command, add these tags to your markdown file:

...

<contents-start />
                     <--- Your table of contents will be inserted right here
<contents-finish />

...

Result should be like this:

...

<contents-start />

- [Usage](#usage)
  - [Generate Table of Contents](#generate-table-of-contents)
  - [Insert Table of Contents into a File](#insert-table-of-contents-into-a-file)
    - [Replace Contents Tags](#replace-contents-tags)
- [Installation](#installation)
  - [Install via PIP](#install-via-pip)
  - [Install from Source](#install-from-source)

<contents-finish />

...

Note, that the insertion replaces everything inside the tags!

That's why, you can call it each time you update your markdown file to automatically update the table of contents. In common, these tags won't be rendered, and you can leave them in the source code if you prefer.

You can also add style="display: none" (or any other attributes) for your tags if needed. The only necessary is to keep the tags naming and put single tag on a single line (multiline tags do not supported).

Replace Contents Tags

If you'd like to insert table of contents but don't want to leave these contents tags, just call the command with both --insert and --replace-tags flags:

md-contents-generator README.md --insert --replace-tags

However, in this case, you will not be able to update you table of contents, and will have to generate and insert the table of contents each time manually.

Metadata

Release files for markdown-contents-generator 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markdown-contents-generator 1.0.1
File Size Uploaded Provenance Actions
markdown_contents_generator-1.0.1.tar.gz 7.3 kB Without provenance Details for markdown_contents_generator-1.0.1.tar.gz

Release files / markdown_contents_generator-1.0.1.tar.gz

Download URL markdown_contents_generator-1.0.1.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
384df825e742dad5aba53cf394e79fd337b4c15c2dfbd4e3890b7df853aed030
BLAKE2b-256 checksum
How to use checksums
d3ecc0b673d29f89d8e4982e5998ad5b6149732e43bd6be13d3f66559d39b4d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Security for markdown-contents-generator 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page