{"id":16252301,"url":"https://github.com/remarkablemark/mdtocs","last_synced_at":"2026-03-15T17:20:10.693Z","repository":{"id":37082084,"uuid":"322990775","full_name":"remarkablemark/mdtocs","owner":"remarkablemark","description":"📝 Markdown table of contents generator.","archived":false,"fork":false,"pushed_at":"2025-03-12T16:20:23.000Z","size":3781,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T10:51:42.908Z","etag":null,"topics":["javascript","markdown","mdtocs","nodejs","npm","parser","table-of-contents","typescript"],"latest_commit_sha":null,"homepage":"https://b.remarkabl.org/mdtocs","language":"TypeScript","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/remarkablemark.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["remarkablemark"],"patreon":"remarkablemark","open_collective":null,"ko_fi":"remarkablemark","tidelift":null,"community_bridge":null,"liberapay":"remarkablemark","issuehunt":null,"otechie":null,"thanks_dev":"u/gh/remarkablemark","custom":["https://b.remarkabl.org/teespring"]}},"created_at":"2020-12-20T04:11:57.000Z","updated_at":"2025-03-12T16:19:10.000Z","dependencies_parsed_at":"2023-02-16T21:01:07.257Z","dependency_job_id":"3b4559bb-f5bc-4238-aaeb-abe20bb925c3","html_url":"https://github.com/remarkablemark/mdtocs","commit_stats":{"total_commits":401,"total_committers":4,"mean_commits":100.25,"dds":"0.23192019950124687","last_synced_commit":"4727bd25a9741d2b3ceb0206b8f1d4ec0e0a91f3"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Fmdtocs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Fmdtocs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Fmdtocs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Fmdtocs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remarkablemark","download_url":"https://codeload.github.com/remarkablemark/mdtocs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244501300,"owners_count":20462837,"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":["javascript","markdown","mdtocs","nodejs","npm","parser","table-of-contents","typescript"],"created_at":"2024-10-10T15:13:09.117Z","updated_at":"2026-03-15T17:20:10.682Z","avatar_url":"https://github.com/remarkablemark.png","language":"TypeScript","funding_links":["https://github.com/sponsors/remarkablemark","https://patreon.com/remarkablemark","https://ko-fi.com/remarkablemark","https://liberapay.com/remarkablemark","https://thanks.dev/u/gh/remarkablemark","https://b.remarkabl.org/teespring"],"categories":[],"sub_categories":[],"readme":"# mdtocs\n\n[![NPM](https://nodei.co/npm/mdtocs.png)](https://www.npmjs.com/package/mdtocs)\n\n[![NPM version](https://img.shields.io/npm/v/mdtocs.svg)](https://www.npmjs.com/package/mdtocs)\n[![build](https://github.com/remarkablemark/mdtocs/actions/workflows/build.yml/badge.svg)](https://github.com/remarkablemark/mdtocs/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/remarkablemark/mdtocs/branch/master/graph/badge.svg?token=IK2QDLEOVB)](https://codecov.io/gh/remarkablemark/mdtocs)\n\n[Markdown](https://wikipedia.org/wiki/Markdown) table of contents generator:\n\n```\nmdtocs(string)\n```\n\nThis library uses [regex](https://developer.mozilla.org/docs/Web/JavaScript/Guide/Regular_Expressions) to parse [Markdown headings](https://www.markdownguide.org/basic-syntax/#headings). As a result, edge cases like headings with links and images won't be generated correctly. Inspired by the [blog post](https://b.remarkabl.org/3rgdgCk).\n\n#### Example\n\n```js\nconst { mdtocs } = require('mdtocs');\nmdtocs('# Hello, World!'); // '- [Hello, World!](#hello-world)'\n```\n\n[Site](https://b.remarkabl.org/mdtocs) | [JSFiddle](https://jsfiddle.net/remarkablemark/dr03pLxn/)\n\n## Install\n\n[NPM](https://www.npmjs.com/package/mdtocs):\n\n```sh\nnpm install mdtocs --save\n```\n\n[Yarn](https://yarnpkg.com/package/mdtocs):\n\n```sh\nyarn add mdtocs\n```\n\n[CDN](https://unpkg.com/mdtocs/):\n\n```html\n\u003cscript src=\"https://unpkg.com/mdtocs@latest/umd/mdtocs.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  window.mdtocs.mdtocs(/* string */);\n\u003c/script\u003e\n```\n\n## Usage\n\nImport with ES Modules:\n\n```js\nimport { mdtocs } from 'mdtocs';\n```\n\nOr require with CommonJS:\n\n```js\nconst { mdtocs } = require('mdtocs');\n```\n\nGenerate table of contents from Markdown:\n\n```js\nmdtocs(`\n# Heading 1\n## Heading 2\n### Heading 3\n`);\n```\n\nOutput:\n\n```md\n- [Heading 1](#heading-1)\n  - [Heading 2](#heading-2)\n    - [Heading 3](#heading-3)\n```\n\nIf the first argument is not a string, then an error will be thrown:\n\n```js\nmdtocs(); // TypeError: First argument must be a string\n```\n\n## Testing\n\nRun tests with coverage:\n\n```sh\nnpm test\n```\n\nRun tests in watch mode:\n\n```sh\nnpm run test:watch\n```\n\nLint files:\n\n```sh\nnpm run lint\n```\n\nFix lint errors:\n\n```sh\nnpm run lint:fix\n```\n\n## Release\n\nRelease is automated with [Release Please](https://github.com/googleapis/release-please).\n\n## License\n\n[MIT](https://github.com/remarkablemark/mdtocs/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablemark%2Fmdtocs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremarkablemark%2Fmdtocs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablemark%2Fmdtocs/lists"}