To automatically generate Table of Contents (TOC) for markdown file, especially for README.md of Github.com
Project description
toc4github
The toc4github
is a very tiny tool to automatically generate Table of
Contents (TOC) for Markdown file, especially for README.md in Github.com.
It might also be used for other markdown rendering system, but
I never tested! :)
Install
$ pip install toc4github
$ python -m toc4github -h # inline help
Usage
You should insert a placeholder which is {toc}
in README.md. The
placeholder ocuppies a whole line. Then:
$ python -m toc4github [-d] [-t TITLE] <path/to/README.md>
Now, the placeholder is replaced by TOC generated with an optional title, and your markdown file is updated.
Or, you can call make_toc
interface in your python code. It returns
the TOC as string in accordance with input, and you can do anything
you want with it.
# how to import
from toc4github import make_toc
# signature
make_toc(lines: Iterable[str]|str) -> str
Showcase
In addition, All my repos' TOC are generated by toc4github. Have fun ... ^___^
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 toc4github-0.17-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 464f862927590f92c34c39f41d4c9fdc5cd4c6251c06d155ca19c774d558255f |
|
MD5 | 85d0a84f55e00de9ec171af3dbf84a37 |
|
BLAKE2b-256 | 7828359de1e2f602edf29f754afd89b2719c73efd8d29f67e55fdaec70046d5a |