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
Hashes for toc_markdown-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0a50901c9b6b3c84e985bd36a271316d0010d4703d88439eba2860228c1865a |
|
MD5 | 5c64aa0bc7c9ffbaa89e3dada772f300 |
|
BLAKE2b-256 | 359a356ecf27e7ec8990922ab87ca55a6a5be0beeae1eb9e8159eb66fb28c9fd |