{"id":13502263,"url":"https://github.com/rasbt/markdown-toclify","last_synced_at":"2025-04-09T21:23:20.892Z","repository":{"id":17762839,"uuid":"20620731","full_name":"rasbt/markdown-toclify","owner":"rasbt","description":"A Python command line tool that creates a Table of Contents for Markdown documents","archived":false,"fork":false,"pushed_at":"2018-07-13T02:23:51.000Z","size":3540,"stargazers_count":93,"open_issues_count":5,"forks_count":42,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T20:06:12.008Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rasbt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.txt","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-08T16:23:49.000Z","updated_at":"2024-12-08T16:56:19.000Z","dependencies_parsed_at":"2022-06-29T20:44:35.946Z","dependency_job_id":null,"html_url":"https://github.com/rasbt/markdown-toclify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasbt%2Fmarkdown-toclify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasbt%2Fmarkdown-toclify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasbt%2Fmarkdown-toclify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasbt%2Fmarkdown-toclify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rasbt","download_url":"https://codeload.github.com/rasbt/markdown-toclify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248113095,"owners_count":21049783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:02:08.005Z","updated_at":"2025-04-09T21:23:20.844Z","avatar_url":"https://github.com/rasbt.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"markdown-toclify\n================\n\nmarkdown_toclify.py is a Python command line script that adds a **Table of Contents** with internal section-links to Markdown documents.\n\nThis project is hosted at: [https://github.com/rasbt/markdown-toclify](https://github.com/rasbt/markdown-toclify).\n\n**Compatible to [CommonMark](http://commonmark.org) (formerly known as Common Markdown).**\n\nSebastian Raschka 2014-2015\n\n\n\u003chr\u003e\n\n\n- [Usage](#usage)\n    - [Command line arguments](#command-line-arguments)\n    - [Using the Python module](#useing-the-python-module)\n- [Examples](#examples)\n    - [Basic usage](#basic-usage)\n    \t- [Input file](#input-file)\n    \t- [Simple output file](#simple-output-file)\n    - [Advanced options](#advanced-options)\n    - [Output file with back-to-top links and vertical space](#output-file-with-back-to-top-links-and-vertical-space)\n    - [Heading level exclusion](#output-file-with-back-to-top-links-and-vertical-space)\n    - [TOC insertion at a placeholder position](#toc-insertion-at-a-placeholder-position)\n\n\u003chr\u003e\n\n**Requires:**  \n\n- [Python 2.7.x or 3.x](https://www.python.org/downloads/)\n- [argparse](https://pypi.python.org/pypi/argparse)\n\n\u003cbr\u003e\n\n# Usage\n[[back to top](#markdown-toclify)]\n\nYou can simply copy the stand_alone script [./markdown_toclify/markdown_toclify.py](./markdown_toclify/markdown_toclify.py) to a local directory on your computer and use it from there.\n\nThe basic usage is quite simple, you just need to provide a Markdown-formatted input file and the modified Markdown contents will be printed to the standard output screen.\n\n\n\t./markdown_toclify.py input.md\n\n\u003cbr\u003e\n\n## Command line arguments\n[[back to top](#markdown-toclify)]\n\n\u003cpre\u003epositional arguments:\n  input.md              path to the Markdown input file\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -o output.md, --output output.md\n                        path to the Markdown output file\n  -b, --back_to_top     add [back to top] links.\n  -g, --github          omits id-anchor tags (recommended for GitHub)\n  -s pixels, --spacer pixels\n                        add horizontal space (in pixels) after the table of contents\n  -n, --nolink          create the table of contents without internal links\n  -e EXCLUDE_H, --exclude_h EXCLUDE_H\n                        exclude eading levels, e.g., \"2,3\" to exclude all level 2 and 3 headings\n  --placeholder PLACEHOLDER\n                        inserts TOC at the placeholder string instead of inserting it on top of the document\n  --no_toc_header       suppresses the Table of Contents header\n  --remove_dashes       Removes dashes from generated slugs\n  -v, --version         show program's version number and exit\n\u003c/pre\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Using the Python module\n[[back to top](#markdown-toclify)]\n\nAlternatively, markdown_toclify can be installed via pip\n\n\tpip install markdown_toclify\n\nand used from the command line as\n\n\tpython -m markdown_toclify -h\n\nFurthermore, markdown_toclify can also be imported as module and be used within Python. For example,\n\n    from markdown_toclify import markdown_toclify\n    cont = markdown_toclify(input_file='/Users/sebastian/Desktop/test_input.md')\n\nThe markdown_toclify module has the same functionality as the command line tool. For more information about the usage, please refer to the help function via\n\n    help(markdown_toclify)\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n#Examples\n[[back to top](#markdown-toclify)]\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Basic usage\n\n\u003cbr\u003e\n\n### Input file\n[[back to top](#markdown-toclify)]\n\n![Input file](./images/example_1.png)\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n### Simple output file\n[[back to top](#markdown-toclify)]\n\nCommand:\n\n\t./markdown_toclify.py input.md -o output.md\n\n\u003cbr\u003e\n\n![Output file 1](./images/example_2.png)\n\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n## Advanced options\n\n\u003cbr\u003e\n\n\n### Output file with back-to-top links and vertical space\n[[back to top](#markdown-toclify)]\n\nCommand:\n\n\t./markdown_toclify.py input.md -o output.md -b -s 100\n\n\u003cbr\u003e\n\n![Output file 2](./images/example_3.png)\n\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n### Heading level exclusion\n[[back to top](#markdown-toclify)]\n\nCommand:\n\n\t./markdown_toclify.py test_input_2.md -o test2_output.md --exclude_h 2,3\n\n![Output file 3](./images/example_4.png)\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n### TOC insertion at a placeholder position\n[[back to top](#markdown-toclify)]\n\nCommand:\n\n\t./markdown_toclify.py test_input_3.md -o test3_output.md --placeholder ??placeholder??\n\n\n**Input**\n\u003cbr\u003e\n\n![Input file 3](./images/example_5.png)\n\n**Output**\n\n![Output file 4](./images/example_6.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frasbt%2Fmarkdown-toclify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frasbt%2Fmarkdown-toclify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frasbt%2Fmarkdown-toclify/lists"}