Skip to main content

Generate TOC for markdown files

Project description

tocs

PyPI

tocs is a simple CLI application written in Python that generates the table of contents (TOC) section for markdown files.
As a person who loves to write personal technical notes in markdown files, I needed something simple to use.

How to install and use tocs

Prerequisites: Python 3.11.9+

Installation

pip install tocs

Basic usage:

  • tocs input_file.md - Generate TOC for the file
  • tocs --depth 2 input_file.md - Limit the TOC generation to headers up to a specified depth
  • tocs --help - Show usage instructions
  • tocs --version - Display version information

tocs example

Given the following markdown file input_file.md:

<!-- init-tocs -->
<!-- end-tocs -->

# header 1
Lorem ipsum dolor sit amet...

## header 2
Lorem ipsum dolor sit amet...

### header 3
Lorem ipsum dolor sit amet...

Run tocs input_file.md and here's the output:

<!-- init-tocs -->
- [header 1](#header-1)
    - [header 2](#header-2)
        - [header 3](#header-3)

<!-- end-tocs -->

# header 1
Lorem ipsum dolor sit amet...

## header 2
Lorem ipsum dolor sit amet...

### header 3
Lorem ipsum dolor sit amet...

Development

  • create venv: python -m venv .venv
  • activate venv: source .venv/bin/activate
  • install project and dependencies (editable mode): pip install -e .[dev]
  • deactivate venv: deactivate

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

tocs-1.0.3.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tocs-1.0.3-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file tocs-1.0.3.tar.gz.

File metadata

  • Download URL: tocs-1.0.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for tocs-1.0.3.tar.gz
Algorithm Hash digest
SHA256 0ae084db2c6c540deef74f3866d93723163e556af8b332763cef0aa4c4ce28d2
MD5 4fbd1b103e9ea04a649276b32229b473
BLAKE2b-256 aecc92fd72fcbaa3b817e503aefd57ade4e58a4c3c9044e125c7e167ddbb929a

See more details on using hashes here.

File details

Details for the file tocs-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: tocs-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for tocs-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 29bb7f6254a6135a335ccf3cdb3b15c84c66e7a0e78daea895477c5d3e3b1979
MD5 34f9c4e349bd840021268c773d16402a
BLAKE2b-256 9a6dfcc95c20320585bc502a30442f8d83d2904d899e17614b1a76391a7120db

See more details on using hashes here.

Supported by

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