Generate TOC for markdown files
Project description
tocs
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+ and pipx installed (pip install pipx).
At the moment only a manual installation is available:
- clone the repository
- from the root of the repository:
pipx install . - to upgrade tocs version:
pipx upgrade tocs
Basic usage:
tocs input_file.md- Generate TOC for the filetocs --help- Show usage instructionstocs --version- Display version information
tocs example
Given the following markdown file input_file.md:
# header 1
Lorem ipsum dolor sit amet...
## header 2
Lorem ipsum dolor sit amet...
### header 3
Lorem ipsum dolor sit amet...
Add two tags where you want the TOCs table:
<!-- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tocs-1.0.2.tar.gz.
File metadata
- Download URL: tocs-1.0.2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bb4bed50eafb30e8a5fc8dda0b776562921a7ae0221c0f451f865fb36886eb0
|
|
| MD5 |
fe179a509cc0c67aad1305c12bd5afcf
|
|
| BLAKE2b-256 |
5b4036e632904778a9f346b1ab08cea6084be624f6c29b91fbce112bc945281e
|
File details
Details for the file tocs-1.0.2-py3-none-any.whl.
File metadata
- Download URL: tocs-1.0.2-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.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb4fd838eff7978f2232157f1eb9427bf08f8cc18e3fe64ec40f811c699a04ab
|
|
| MD5 |
90bdbf1f650b4bbf5919e794f6d61ce4
|
|
| BLAKE2b-256 |
a6be3aa8aebafa782b06d572900adda446c979f4d45a235fcdbf19ca2a583676
|