Skip to main content

Generate table of contents for Markdown files

Project description

Table of Contents generated with DocToc

DocToc

License PyPI version

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.

Prerequisites

Before installing DocToc, ensure you have the following:

  • Python 3.6+
  • pip (Python package installer)

Installation

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

Usage

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.

Options:

  • --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

Features

  • 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.

GitHub

For more details, visit the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contribution

If you want to contribute, kindly see this contribution

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

doctoc-1.0.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

doctoc-1.0.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file doctoc-1.0.0.tar.gz.

File metadata

  • Download URL: doctoc-1.0.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.14

File hashes

Hashes for doctoc-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0a13183b10a2942b3d4e6f5cc6c250bd7f1729695315e78182be3d21d4886511
MD5 0c71129c605cfbeb83e033e904b6e35b
BLAKE2b-256 50d4b01028d8c033fbe009cb5c7765ddfa722adfe4ae1ca2f39fdc15fa0ebf57

See more details on using hashes here.

File details

Details for the file doctoc-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: doctoc-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.14

File hashes

Hashes for doctoc-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c916a965e2075774f540079374a262111dadfa9d7d3d0adbbe34d16c6669cfad
MD5 971ce9ccf6826e900a43bb4f94392c38
BLAKE2b-256 2f17b498cc174485d8ca4aeaa6893c2d912bdaa81738926da1f2da558ba17b2b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page