Generate a table of contents for a Markdown file.
Project description
Markdown Table of Contents Generator
This tool scans Markdown files to detect headers and subsequently creates a Table of Contents (TOC) with direct links to the respective sections. It either updates an existing TOC or generates a new one if none is found.
Table of Contents
Features
- Automatically generates a table of contents for your Markdown files.
- Either updates an existing TOC or inserts a new one if absent.
- Supports headers of levels 2 to 3.
- Provides clickable links leading to the corresponding sections within the document.
- Preserves the structure and formatting of the Markdown file.
Installation
To install, use pip
or pipx
:
pipx install toc-markdown
Integration with Vim
For a seamless experience in updating the TOC of your Markdown files through Vim, ensure the toc-markdown
tool is either accessible from your PATH or specify its absolute path in the Vim configuration.
-
Include the
toc-markdown
tool in your PATH environment variable, enabling direct execution from Vim.OR
-
If the
toc-markdown
tool isn't in the PATH, specify its absolute path in the Vim configuration provided below.
Next, add the following line to your .vimrc
file:
autocmd FileType markdown nnoremap <buffer> <leader>t :w<cr>:!toc-markdown %:p<cr>:e!<cr>
With this setup, simply press <leader>t
in normal mode when editing a Markdown file in Vim. This will save the file, run the toc-markdown
tool on it, and then reload the edited file to display the refreshed TOC.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file toc-markdown-0.0.2.tar.gz
.
File metadata
- Download URL: toc-markdown-0.0.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe89d8a7ff9f2d0e70a48e872cb974ec927e86f8fe5f677a612108110225eaf7 |
|
MD5 | 68361b9dc60f3273015a19c5ee607bb1 |
|
BLAKE2b-256 | 65ed43c07294a615ec04629685ad2f581fdf5012dacb94b91bd2c4c025aa7d66 |
File details
Details for the file toc_markdown-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: toc_markdown-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0a50901c9b6b3c84e985bd36a271316d0010d4703d88439eba2860228c1865a |
|
MD5 | 5c64aa0bc7c9ffbaa89e3dada772f300 |
|
BLAKE2b-256 | 359a356ecf27e7ec8990922ab87ca55a6a5be0beeae1eb9e8159eb66fb28c9fd |