{"id":50136758,"url":"https://github.com/gadzan/generatoc","last_synced_at":"2026-05-23T22:06:04.409Z","repository":{"id":40768175,"uuid":"263342404","full_name":"gadzan/generatoc","owner":"gadzan","description":"Automatically generate table of content from heading of HTML document","archived":false,"fork":false,"pushed_at":"2023-03-13T06:02:25.000Z","size":1257,"stargazers_count":8,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T16:15:16.911Z","etag":null,"topics":["article-extractor","html-document","ssr","toc","typescript"],"latest_commit_sha":null,"homepage":"","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/gadzan.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}},"created_at":"2020-05-12T13:19:28.000Z","updated_at":"2025-06-26T08:46:41.000Z","dependencies_parsed_at":"2024-10-28T14:28:04.468Z","dependency_job_id":"f7596ef0-55af-496e-93a0-1d7e7883d3cc","html_url":"https://github.com/gadzan/generatoc","commit_stats":{"total_commits":57,"total_committers":4,"mean_commits":14.25,"dds":0.4736842105263158,"last_synced_commit":"fe14bd24c9b0c4a745e737f5e9fa0b0651e5edc7"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/gadzan/generatoc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gadzan%2Fgeneratoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gadzan%2Fgeneratoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gadzan%2Fgeneratoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gadzan%2Fgeneratoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gadzan","download_url":"https://codeload.github.com/gadzan/generatoc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gadzan%2Fgeneratoc/sbom","scorecard":{"id":416923,"data":{"date":"2025-08-11","repo":{"name":"github.com/gadzan/generatoc","commit":"fe14bd24c9b0c4a745e737f5e9fa0b0651e5edc7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/gadzan/generatoc/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/gadzan/generatoc/main.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"42 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr","Warn: Project is vulnerable to: GHSA-566m-qj78-rww5","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-257v-vj4p-3w2h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-7r28-3m3f-r2pr","Warn: Project is vulnerable to: GHSA-r8j5-h5cx-65gg","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T00:09:38.008Z","repository_id":40768175,"created_at":"2025-08-19T00:09:38.008Z","updated_at":"2025-08-19T00:09:38.008Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33413662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T18:09:33.147Z","status":"ssl_error","status_checked_at":"2026-05-23T18:09:31.380Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["article-extractor","html-document","ssr","toc","typescript"],"created_at":"2026-05-23T22:06:03.582Z","updated_at":"2026-05-23T22:06:04.400Z","avatar_url":"https://github.com/gadzan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GeneraToc\n\n[![Travis (.org)](https://img.shields.io/travis/gadzan/generatoc?style=for-the-badge)](https://www.travis-ci.org/gadzan/generatoc)\n[![npm 20downloads](https://img.shields.io/npm/dt/generatoc?label=npm%20downloads\u0026logo=npm\u0026style=for-the-badge)](https://www.npmjs.com/package/generatoc)\n[![npm bundle size](https://img.shields.io/bundlephobia/min/generatoc?style=for-the-badge)](https://www.npmjs.com/package/generatoc)\n[![Coveralls github](https://img.shields.io/coveralls/github/gadzan/generatoc?style=for-the-badge)](https://coveralls.io/github/gadzan/generatoc?branch=master)\n[![License](https://img.shields.io/npm/l/generatoc?style=for-the-badge)](https://github.com/gadzan/generatoc/blob/master/LICENSE)\n[![Version](https://img.shields.io/npm/v/generatoc?logo=npm\u0026label=version\u0026style=for-the-badge)](https://www.npmjs.com/package/generatoc)\n[![GitHub package.json version](https://img.shields.io/github/package-json/v/gadzan/generatoc?logo=github\u0026style=for-the-badge)](github.com/gadzan/generatoc/)\n\nGeneraToc generates a table of contents (TOC) from headings in an HTML document. This is useful for documentation websites or SSR pages because it makes them easier to navigate. \n\nThis library was inspired by [Tocify](https://github.com/gfranko/jquery.tocify.js) and [Tocbot](https://github.com/tscanlin/tocbot), but GeneraToc **uses native DOM** methods with **no other dependencies** and unlike Tocbot, GeneraToc does **NOT rely on id attribute** to navigate to the heading.\n\n## DEMO\n\n[https://gadzan.github.io/generatoc/demo/](https://gadzan.github.io/generatoc/demo/)\n\n## Installation\n\nInstall it with npm.\n\n```bash\n# With npm\nnpm install --save generatoc\n# or yarn\nyarn add generatoc\n# or pnpm\npnpm add generatoc\n```\n\nOR include in browser environment\ninclude the script at the bottom of the page before the closing body tag.\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/generatoc/build/generatoc.min.js\"\u003e\u003c/script\u003e\n```\n\nInclude CSS\n\nin html file\n\n```html\n\u003clink rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/generatoc/build/generatoc.min.css\"\u003e\n```\n\nOR\n\nIf you installed it with npm you might try importing the styles from 'node_modules'\n\n```css\n@import 'generatoc/src/style/main.css';\n```\n\n## Usage\n\nDefine a `div` element with id attribute\n\n```html\n\u003cdiv id=\"toc\"\u003e\u003c/div\u003e\n```\n\n### Use GeneraToc with typescript\n\n```typescript\nimport generatoc from 'generatoc'\n// Typescript\n// (Required) Article content selector, default as '.post-content'\nconst content: string = '.post-content'\n\n// (Optional) Select h2 ~ h5 heading level, it is also a defualt setting if you leave it undefined\nconst heading: string[] = ['h2', 'h3', 'h4', 'h5']\n\n// (Optional) TOC element is append to #toc element, it is also a defualt setting if you leave it undefined\nconst selector: string = '#toc'\n\ngeneratoc.init({ content, heading, selector })\n```\n\n### Use GeneraToc with javascript\n\n```javascript\n// JavaScript\nimport generatoc from 'generatoc'\nconst content = '.post-content'\nconst heading = ['h2', 'h3', 'h4', 'h5']\nconst selector = '#toc'\ngeneratoc.init({ content, heading, selector })\n```\n\n### Use in browser environment\n\n```javascript\nconst content = '.post-content'\nconst heading = ['h2', 'h3', 'h4', 'h5']\nconst selector = '#toc'\ngeneratoc.init({ content, heading, selector })\n```\n\n### You need to know when importing css file\n\n**If the `selector` is not `#toc` you have to modify css file manully**, just replace all `#toc` string with your selector name in css file which can be found at `./node_modules/generatoc/src/style/main.css`\n\n## Development\n\n```bash\nyarn install\nnpm run dev\n```\n\n## Other init options\n\n```javascript\n{\n  // scrollHistory: default to null;\n  // scrollHistory: {\n  //   readableSpace?: boolean;              // Replace url hash string form '%20' to '-';\n  //   replacePattern?: RegExp | string;     // You can also define your own pattern to replace the url hash string;\n  //   replacement?: string;                 // Replacement of the pattern;\n  //   scrollToAfterMounted?: boolean;       // Option to scroll to the title after page mounted; * Only valid when above options are unset;\n  // }\n  // Adds a hash to the page url, to maintain history, when scrolling to a TOC item\n  scrollHistory: false,\n\n  // scrollOffset: Accepts a number; default to 0\n  // Scroll to the target with a vertical offset(pixel). If you have a fixed header in your page, this is what you need to set.\n  scrollOffset: 0,\n\n  // duration: Accepts a number; default to 7\n  // The duration of scroll animation, a larger number means slower scroll. please input with a number larger than 1.\n  duration: 7,\n\n  // fold: Accepts a boolean; default to false\n  // Default show as folded TOC or not\n  fold: false,\n}\n```\n\n## TODO\n\n- [x] Destory method\n- [x] Reload method\n- [x] Development env\n- [x] Test cases\n- [x] Show and close animation\n- [ ] More configurations\n\n## Using with SSR\n\nIf you are using GeneraToc with SSR framwork, like Nuxt.js, please add `transpile` param to `nuxt.config.js`\n\n```javascript\nbuild: {\n  transpile: ['generatoc']\n}\n```\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgadzan%2Fgeneratoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgadzan%2Fgeneratoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgadzan%2Fgeneratoc/lists"}