{"id":21952184,"url":"https://github.com/stefanmaric/simpletoc","last_synced_at":"2025-07-24T15:08:01.940Z","repository":{"id":22693170,"uuid":"97060614","full_name":"stefanmaric/simpletoc","owner":"stefanmaric","description":"Simple Table of Contents generator for DOM and Markdown","archived":false,"fork":false,"pushed_at":"2023-01-04T21:39:12.000Z","size":3917,"stargazers_count":6,"open_issues_count":19,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T08:35:27.191Z","etag":null,"topics":["contents","dom","markdown","md","table","table-of-contents","toc"],"latest_commit_sha":null,"homepage":"https://www.stefanmaric.com/simpletoc/","language":"JavaScript","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/stefanmaric.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2017-07-12T23:38:18.000Z","updated_at":"2021-06-16T21:06:48.000Z","dependencies_parsed_at":"2023-01-11T21:43:52.116Z","dependency_job_id":null,"html_url":"https://github.com/stefanmaric/simpletoc","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanmaric%2Fsimpletoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanmaric%2Fsimpletoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanmaric%2Fsimpletoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanmaric%2Fsimpletoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanmaric","download_url":"https://codeload.github.com/stefanmaric/simpletoc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250372341,"owners_count":21419718,"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":["contents","dom","markdown","md","table","table-of-contents","toc"],"created_at":"2024-11-29T06:24:09.003Z","updated_at":"2025-04-23T04:37:02.025Z","avatar_url":"https://github.com/stefanmaric.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simpletoc\n\nSimple Table of Contents generator for DOM and Markdown. 1.5kb\n\n[![license](https://img.shields.io/github/license/stefanmaric/simpletoc.svg)](./LICENSE)\n[![Travis](https://img.shields.io/travis/stefanmaric/simpletoc.svg)](https://travis-ci.org/stefanmaric/simpletoc)\n[![Coveralls](https://img.shields.io/coveralls/stefanmaric/simpletoc.svg)](https://coveralls.io/github/stefanmaric/simpletoc)\n[![npm](https://img.shields.io/npm/v/simpletoc.svg)](https://www.npmjs.com/package/simpletoc)\n[![Greenkeeper badge](https://badges.greenkeeper.io/stefanmaric/simpletoc.svg)](https://greenkeeper.io/)\n[![npm](https://img.shields.io/npm/dt/simpletoc.svg)](https://www.npmjs.com/package/simpletoc)\n[![GitHub stars](https://img.shields.io/github/stars/stefanmaric/simpletoc.svg?style=flat-square)](https://github.com/stefanmaric/simpletoc/stargazers)\n\n\n## Quick dive\n\n### For the DOM\n\n```javascript\nsimpletoc.domToc({\n  // Only search for content in a specific place.\n  root: '.content',\n  // Only use headings from 1 to 3 levels.\n  selector: 'h1, h2, h3',\n  // Where to place the generated Table of Contents.\n  target: '.table-of-contents-placeholder',\n  // Use an unordered list (bullet list, no numbers).\n  type: 'ul',\n})\n```\n\n### For Markdown\n\n```javascript\nsimpletoc.mdToc(markdownText, {\n  // Place to inject the generated table of contents.\n  target: /Table of contents here/,\n  // Use an unordered list (bullet list, no numbers).\n  type: 'ul',\n})\n```\n\n\n## Why?\n\nI needed to generate a table of contents and all I found was kind of overkill or bulked.\n\n\n## Install\n\n```shell\n$ npm install simpletoc\n```\n\nOr use a CDN like [jsDelivr](https://www.jsdelivr.com/package/npm/simpletoc).\n\n\n## Browser support\n\n`simpletoc` should work in every major browser and every node.js LTS version. Distribution files are\ntranspiled with babel and target is defined in the [`.browserlistrc` file](./.browserslistrc).\n[See the list of browsers here](https://browserl.ist/?q=%3E1%25%2C+not+op_mini+all%2C+not+dead).\n\n\n## Some alternatives\n\n- https://github.com/gajus/contents\n- https://github.com/jgallen23/toc\n- https://github.com/gfranko/jquery.tocify.js\n- https://github.com/tscanlin/tocbot\n- https://github.com/n1k0/toctoc\n- https://github.com/aslushnikov/table-of-contents-preprocessor\n- https://github.com/Oktavilla/markdown-it-table-of-contents\n- https://github.com/gajus/markdown-contents\n- https://github.com/thlorenz/doctoc\n\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](./CONTRIBUTING.md). ♥\n\n\n## License\n\n[MIT](./LICENSE) ♥\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanmaric%2Fsimpletoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanmaric%2Fsimpletoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanmaric%2Fsimpletoc/lists"}