{"id":16760519,"url":"https://github.com/bjoernricks/mdit-py-toc","last_synced_at":"2025-07-25T22:05:01.499Z","repository":{"id":220678534,"uuid":"751742116","full_name":"bjoernricks/mdit-py-toc","owner":"bjoernricks","description":"A table of contents (TOC) plugin for markdown-it-py","archived":false,"fork":false,"pushed_at":"2025-07-01T05:40:17.000Z","size":147,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-01T06:30:35.724Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bjoernricks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-02-02T08:22:00.000Z","updated_at":"2025-07-01T05:40:19.000Z","dependencies_parsed_at":"2024-03-11T16:46:01.782Z","dependency_job_id":"c4b50ba0-6fc5-43ef-8c60-0caf54152713","html_url":"https://github.com/bjoernricks/mdit-py-toc","commit_stats":null,"previous_names":["bjoernricks/mdit-py-toc"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bjoernricks/mdit-py-toc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoernricks%2Fmdit-py-toc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoernricks%2Fmdit-py-toc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoernricks%2Fmdit-py-toc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoernricks%2Fmdit-py-toc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjoernricks","download_url":"https://codeload.github.com/bjoernricks/mdit-py-toc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoernricks%2Fmdit-py-toc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267070318,"owners_count":24030970,"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","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-13T04:23:45.942Z","updated_at":"2025-07-25T22:05:01.405Z","avatar_url":"https://github.com/bjoernricks.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mdit-py-toc \u003c!-- omit in toc --\u003e\n\nA table of contents (TOC) plugin for [markdown-it-py](https://markdown-it-py.readthedocs.io/en/latest/)\nbased on [markdown-it-toc-done-right](https://github.com/nagaozen/markdown-it-toc-done-right).\n\n- [Installation](#installation)\n  - [Install using poetry](#install-using-poetry)\n  - [Install using pip](#install-using-pip)\n- [Options](#options)\n- [Usage](#usage)\n\n## Installation\n\n### Install using poetry\n\nBecause **mdit-py-toc** is a plugin, you most likely need a tool to\nhandle Python package dependencies and Python environments. Therefore we\nstrongly recommend using [poetry].\n\nYou can install the latest stable release and add it as a dependency for your\ncurrent project using [poetry]\n\n```\npoetry add mdit-py-toc\n```\n\n### Install using pip\n\n\u003e [!NOTE]\n\u003e The `pip install` command does no longer work out-of-the-box in newer\n\u003e distributions like Ubuntu \u003e= 23.04 because of [PEP 668](https://peps.python.org/pep-0668).\n\nYou can install the latest stable release from the Python Package Index (pypi)\nusing [pip]\n\n```\npython -m pip install mdit-py-toc\n```\n\n## Options\n\n| Name      | Description                                                            | Default               |\n| --------- | ---------------------------------------------------------------------- | --------------------- |\n| pattern   | The pattern serving as the TOC placeholder in your markdown            | `r\"^(\\[TOC\\]\")`       |\n| level     | Heading level to apply anchors on or iterable of selected levels       | `(1, 2)`              |\n| list_type | Type of list (`\"ul\"` for unordered, `\"ol\"` for ordered)                | `\"ul\"`                |\n| slug_func | Function to convert heading title text to id slugs for link references | `mdit_py_toc.slugify` |\n\n## Usage\n\n`mdit-py-toc` works best in conjunction with the [anchors plugin](https://mdit-py-plugins.readthedocs.io/en/latest/#heading-anchors).\n\n```python\nfrom markdown_it import MarkdownIt\nfrom mdit_py_plugins.anchors import anchors_plugin\nfrom mdit_py_toc import toc_plugin, slugify\n\nmd = (\n  MarkdownIt()\n  .use(anchors_plugin, permalink=True, slug_func=slugify)\n  .use(toc_plugin, list_type=\"ol\")\n)\nmarkdown = \"\"\"\n# A Page\n\n[TOC]\n\n## Section 1\n\n## Section 2\n\"\"\"\nhtml = md.render(markdown)\n```\nCreates the following HTML output\n```\n\u003ch1 id=\"a-page\"\u003eA Page \u003ca class=\"header-anchor\" href=\"#a-page\"\u003e¶\u003c/a\u003e\u003c/h1\u003e\n\u003cnav\u003e\n\u003col\u003e\n\u003cli\u003e\u003ca href=\"#a-page\"\u003eA Page \u003c/a\u003e\u003col\u003e\n\u003cli\u003e\u003ca href=\"#section-1\"\u003eSection 1 \u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#section-2\"\u003eSection 2 \u003c/a\u003e\u003c/li\u003e\n\u003c/ol\u003e\u003c/li\u003e\n\u003c/ol\u003e\u003c/nav\u003e\n\u003ch2 id=\"section-1\"\u003eSection 1 \u003ca class=\"header-anchor\" href=\"#section-1\"\u003e¶\u003c/a\u003e\u003c/h2\u003e\n\u003ch2 id=\"section-2\"\u003eSection 2 \u003ca class=\"header-anchor\" href=\"#section-2\"\u003e¶\u003c/a\u003e\u003c/h2\u003e\n```\n\n[poetry]: https://python-poetry.org/\n[pip]: https://pip.pypa.io/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjoernricks%2Fmdit-py-toc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjoernricks%2Fmdit-py-toc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjoernricks%2Fmdit-py-toc/lists"}