{"id":27950,"library":"mdformat-toc","title":"mdformat-toc","description":"A plugin for mdformat that automatically generates a table of contents (TOC) in Markdown documents. Version 0.5.0, requires Python >=3.9. Release cadence is low, maintained as part of the mdformat plugin ecosystem.","status":"active","version":"0.5.0","language":"python","source_language":"en","source_url":"https://github.com/hukkin/mdformat-toc","tags":["mdformat","plugin","table-of-contents","markdown"],"install":[{"cmd":"pip install mdformat-toc","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"mdformat-toc is a plugin for mdformat; mdformat must be installed.","package":"mdformat","optional":false}],"imports":[{"note":"Plugin is auto-discovered by mdformat; explicit import is optional.","symbol":"mdformat_toc","correct":"import mdformat_toc"}],"quickstart":{"code":"import mdformat\nimport os\n\n# Create a sample Markdown file\nmd_content = \"\"\"# Title\n\n## Section 1\n\nContent here.\n\n## Section 2\n\nMore content.\n\"\"\"\n\n# Format with mdformat, using the toc plugin\nformatted = mdformat.text(md_content, extensions={\"toc\"})\nprint(formatted)\n","lang":"python","description":"Formats a Markdown string and generates a table of contents using the plugin."},"warnings":[{"fix":"Upgrade to Python 3.9+","message":"Python 3.8 support was dropped in version 0.4.0. Use Python 3.9+.","severity":"deprecated","affected_versions":"<=0.3.2"},{"fix":"Install mdformat-toc in the same environment: pip install mdformat mdformat-toc","message":"Plugin auto-registration may not work if mdformat-toc is not installed in the same environment as mdformat. Ensure both are installed together.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run `pip install mdformat-toc` to install the plugin.","cause":"Plugin not installed or not in the current Python environment.","error":"ModuleNotFoundError: No module named 'mdformat_toc'"},{"fix":"Ensure all headers are properly formatted (e.g., no empty headings, consistent indentation).","cause":"The Markdown content has syntax issues that prevent TOC generation (e.g., incomplete headings).","error":"mdformat.exceptions.ParsingError: ... toc ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}