Generate a table of contents for a Markdown file.
Project description
Markdown Table of Contents Generator
This Python script automates the generation and management of a Table of Contents (TOC) for your Markdown files. It scans the Markdown file for headers and creates a TOC with clickable links to the respective sections. The script can update an existing TOC or insert a new one if none exists.
Table of Contents
Features
- Automatic generation of a table of contents for your Markdown files.
- Updates an existing TOC or inserts a new one if not present.
- Supports headers of levels 2 to 3.
- Generates clickable links to the corresponding sections within the document.
- Maintains the structure and formatting of the Markdown file.
Getting Started
Prerequisites
- Python 3.6
Installation
git clone https://github.com/sderev/toc-markdown.git
Integration with Vim
To streamline the process of updating the TOC in your Markdown files, ensure that the toc-markdown
script is either accessible from your PATH or provide its absolute path in the Vim configuration.
-
Add the
toc-markdown
script to your PATH environment variable. This step allows Vim to execute the script directly.OR
-
If the
toc-markdown
script is not in the PATH, provide its absolute path in the Vim configuration below.
Then, open your .vimrc
file and add the following line:
autocmd FileType markdown nnoremap <buffer> <leader>t :w<cr>:!toc-markdown %:p<cr>:e!<cr>
With the above configuration, you can press <leader>t
while in normal mode within a Markdown file in Vim. It will save the file, execute the toc-markdown
script on it, and reload the updated file, displaying the updated 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.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 754745b6e1029a17f23759826db2e229126b219ab7fbf34715a1996b5852b54b |
|
MD5 | ce10ec513f4ae01b64e95f6bfa20449d |
|
BLAKE2b-256 | 9e082b2a223917320a518a8a0387b509d371661d88b0f814085b123adb649259 |