{"id":15415719,"url":"https://github.com/inokawa/remark-extract-toc","last_synced_at":"2025-07-22T02:38:26.013Z","repository":{"id":40770940,"uuid":"260992375","full_name":"inokawa/remark-extract-toc","owner":"inokawa","description":"remark plugin to store table of contents","archived":false,"fork":false,"pushed_at":"2023-12-15T20:19:10.000Z","size":725,"stargazers_count":8,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-04T06:09:59.956Z","etag":null,"topics":["markdown","mdast","remark","remark-plugin","unified"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/remark-extract-toc","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/inokawa.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},"funding":{"github":["inokawa"]}},"created_at":"2020-05-03T18:15:52.000Z","updated_at":"2025-01-31T09:46:04.000Z","dependencies_parsed_at":"2023-12-15T21:47:11.618Z","dependency_job_id":"6059fc63-232e-428f-b788-3c690b1c91b1","html_url":"https://github.com/inokawa/remark-extract-toc","commit_stats":{"total_commits":38,"total_committers":2,"mean_commits":19.0,"dds":"0.39473684210526316","last_synced_commit":"27ab26c2bc58d5acb534a2adbb892a379dbd3d72"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/inokawa/remark-extract-toc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-extract-toc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-extract-toc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-extract-toc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-extract-toc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inokawa","download_url":"https://codeload.github.com/inokawa/remark-extract-toc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-extract-toc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266413530,"owners_count":23924748,"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-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["markdown","mdast","remark","remark-plugin","unified"],"created_at":"2024-10-01T17:09:23.012Z","updated_at":"2025-07-22T02:38:25.986Z","avatar_url":"https://github.com/inokawa.png","language":"JavaScript","funding_links":["https://github.com/sponsors/inokawa"],"categories":[],"sub_categories":[],"readme":"# remark-extract-toc\n\n![npm](https://img.shields.io/npm/v/remark-extract-toc) ![npm](https://img.shields.io/npm/dw/remark-extract-toc) ![check](https://github.com/inokawa/remark-extract-toc/workflows/check/badge.svg)\n\n[remark](https://github.com/remarkjs/remark) plugin to store table of contents.\n\nThis plugin extracts only `Heading` from [mdast](https://github.com/syntax-tree/mdast) markdown, then converts them to a nested object tree keeping the depth.\n\n# Install\n\n```\nnpm install remark-extract-toc\n```\n\n# Usage\n\n```javascript\nvar unified = require(\"unified\");\nvar markdown = require(\"remark-parse\");\nvar extractToc = require(\"remark-extract-toc\");\n\nvar fs = require(\"fs\");\nvar text = fs.readFileSync(\"example.md\", \"utf8\");\n\nvar processor = unified().use(markdown).use(extractToc);\n\nvar node = processor.parse(text);\nvar tree = processor.runSync(node);\nconsole.log(tree);\n```\n\nThis `example.md`\n\n```\n# Alpha\n\naaaa\n\n## Bravo\n\nbbbb\n\n### Charlie\n\ncccc\n\n## Delta\n\ndddd\n```\n\nwill be converted by this library like...\n\n```\n[\n  {\n    depth: 1,\n    value: \"Alpha\",\n    children: [\n      {\n        depth: 2,\n        value: \"Bravo\",\n        children: [{ depth: 3, value: \"Charlie\", children: [] }],\n      },\n      {\n        depth: 2,\n        value: \"Delta\",\n        children: [],\n      },\n    ],\n  },\n]\n```\n\n# API\n\n`remark().use(toc[, options])`\n\n## Options\n\n| Key     | Default | Type     | Description                                                                                                                                     |\n| ------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |\n| flatten | false   | boolean  | If true, toc is extracted as a list not nested.                                                                                                 |\n| keys    | []      | string[] | Add extra field to tree object. For example, use [remark-slug](https://github.com/remarkjs/remark-slug) to add id and set `{ keys: [\"data\"] }`. |\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finokawa%2Fremark-extract-toc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finokawa%2Fremark-extract-toc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finokawa%2Fremark-extract-toc/lists"}