Table of Contents generated with DocToc
DocToc is a command-line tool built with Python that automatically generates and updates table of contents (TOC) for Markdown files. It scans through your Markdown file, identifies headers, and creates a TOC with clickable links.
Before installing DocToc, ensure you have the following:
- Python 3.6+
- pip (Python package installer)
You can install DocToc using pip:
pip install doctoc
Alternatively, you can install it from the source on GitHub:
git clone https://github.com/ktechhub/doctoc.git
cd doctoc
python setup.py install
Generate a table of contents for a Markdown file:
doctoc --help
Usage: doctoc [OPTIONS] MARKDOWN_FILE
Generate or update a table of contents for Markdown files and optionally
check hyperlinks.
Args:
markdown_file (str): Path to the Markdown file to process.
outfile (str, optional): Output file path. If specified, writes the modified content to this file instead of overwriting the original.
check_links (bool): Flag to enable checking the validity of hyperlinks found in the Markdown file.
Options:
-o, --outfile TEXT Specify an output file instead of overwriting.
-cl, --check-links Check validity of hyperlinks.
--help Show this message and exit.
-
--outfile
: Specify an output file instead of overwriting. -
--check-links
: Check the validity of hyperlinks within the Markdown file.
Example with options:
doctoc README.md --check-links
Output
Success: wrote TOC to README.md
Checking hyperlinks...
VALID: [DocToc](https://github.com/ktechhub/doctoc)
VALID: [DocToc](#doctoc)
VALID: [Prerequisites](#prerequisites)
VALID: [Installation](#installation)
VALID: [Usage](#usage)
VALID: [Options:](#options)
VALID: [Features](#features)
VALID: [GitHub](#github)
VALID: [License](#license)
VALID: [GitHub repository](https://github.com/ktechhub/doctoc)
doctoc README.md --outfile README_with_toc.md
Output
Success: wrote TOC to README_with_toc.md
doctoc README.md --outfile README_with_toc.md --check-links
- Automatically generates a TOC based on Markdown headers.
- Supports customization with options to specify output file and check link validity.
- Simple and easy to use with a command-line interface.
For more details, visit the GitHub repository.
This project is licensed under the MIT License - see the LICENSE file for details.
If you want to contribute, kindly see this contribution