https://github.com/xinlin-z/toc4github
Generate Table of Contents (TOC) for Github Markdown file (like README.md) automatically
https://github.com/xinlin-z/toc4github
github markdown python toc toc-generator
Last synced: 4 months ago
JSON representation
Generate Table of Contents (TOC) for Github Markdown file (like README.md) automatically
- Host: GitHub
- URL: https://github.com/xinlin-z/toc4github
- Owner: xinlin-z
- License: other
- Created: 2020-11-16T07:42:20.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-28T12:14:40.000Z (over 1 year ago)
- Last Synced: 2025-01-18T06:55:04.336Z (5 months ago)
- Topics: github, markdown, python, toc, toc-generator
- Language: Python
- Homepage:
- Size: 67.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# toc4github
* [Install](#Install)
* [Usage](#Usage)
* [Showcase](#Showcase)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
``` shell
$ 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:``` shell
$ python -m toc4github [-d] [-t TITLE]
```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.``` python
# how to import
from toc4github import make_toc
# signature
def make_toc(lines: Iterable[str]|str) -> str: ...
```## Showcase

In addition, All my repos' TOC are generated by toc4github.
Have fun ... ^___^