{"id":20790709,"url":"https://github.com/markedjs/marked-gfm-heading-id","last_synced_at":"2026-04-07T08:02:28.615Z","repository":{"id":37957191,"uuid":"368038960","full_name":"markedjs/marked-gfm-heading-id","owner":"markedjs","description":"Add unique heading ids like GitHub","archived":false,"fork":false,"pushed_at":"2025-03-24T18:29:01.000Z","size":9426,"stargazers_count":19,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T17:36:23.428Z","etag":null,"topics":["extension","gfm","heading","id","marked"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/marked-gfm-heading-id","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/markedjs.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":"2021-05-17T03:02:09.000Z","updated_at":"2025-03-24T18:28:58.000Z","dependencies_parsed_at":"2023-11-13T18:28:28.227Z","dependency_job_id":"6f38d8e7-9a46-4574-ac87-5d99fb99c82e","html_url":"https://github.com/markedjs/marked-gfm-heading-id","commit_stats":{"total_commits":294,"total_committers":4,"mean_commits":73.5,"dds":0.07482993197278909,"last_synced_commit":"482797e2c28d5aec35131d7ab3e928227b9b27d9"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":"markedjs/marked-extension-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markedjs%2Fmarked-gfm-heading-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markedjs%2Fmarked-gfm-heading-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markedjs%2Fmarked-gfm-heading-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markedjs%2Fmarked-gfm-heading-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markedjs","download_url":"https://codeload.github.com/markedjs/marked-gfm-heading-id/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247550690,"owners_count":20956987,"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":["extension","gfm","heading","id","marked"],"created_at":"2024-11-17T15:37:03.833Z","updated_at":"2026-04-07T08:02:28.608Z","avatar_url":"https://github.com/markedjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# marked-gfm-heading-id\n\nAdd ids to headings like GitHub.\n\n# Usage\n\n```js\nimport { marked } from \"marked\";\nimport { gfmHeadingId } from \"marked-gfm-heading-id\";\n\n// or UMD script\n// \u003cscript src=\"https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js\"\u003e\u003c/script\u003e\n// \u003cscript src=\"https://cdn.jsdelivr.net/npm/marked-gfm-heading-id/lib/index.umd.js\"\u003e\u003c/script\u003e\n\nconst options = {\n\tprefix: \"my-prefix-\",\n};\n\nmarked.use(gfmHeadingId(options));\n\nmarked(\"# heading\");\n// \u003ch1 id=\"my-prefix-heading\"\u003eheading\u003c/h1\u003e\n```\n\n## Get heading list\n\n`getHeadingList` is a function that is exported to provide the list of headings.\n\nThe headings will each be an object with the following properties:\n - `text`: The rendered HTML for the heading\n - `level`: The heading level (1-7)\n - `raw`: The raw text (stripped of HTML rendering if any; this is usefull for situation like `marked(\"# [heading](./link)\");`)\n - `id`: The id given to the heading including any prefix\n\n```js\nimport { marked } from \"marked\";\nimport { gfmHeadingId, getHeadingList } from \"marked-gfm-heading-id\";\n\nmarked.use(gfmHeadingId({prefix: \"my-prefix-\"}), {\n\thooks: {\n\t\tpostprocess(html) {\n\t\t\tconst headings = getHeadingList();\n\n\t\t\treturn `\n\u003cul id=\"table-of-contents\"\u003e\n\t${headings.map(({id, raw, level}) =\u003e `\u003cli\u003e\u003ca href=\"#${id}\" class=\"h${level}\"\u003e${raw}\u003c/a\u003e\u003c/li\u003e`)}\n\u003c/ul\u003e\n${html}`;\n\t\t}\n\t}\n});\n\nmarked(\"# heading\");\n// \u003cul id=\"table-of-contents\"\u003e\n//   \u003cli\u003e\u003ca href=\"#my-prefix-heading\" class=\"h1\"\u003eheading\u003c/a\u003e\u003c/li\u003e\n// \u003c/ul\u003e\n// \u003ch1 id=\"my-prefix-heading\"\u003eheading\u003c/h1\u003e\n```\n\n## Clear Heading List\n\n`resetHeadings` is a function to purge the stored list of headings and reset the Slugger. This is only needed when the globalSlugs option ( see below) is set to true and you wish to reset the slugger and exportable Headers list.\n\n## `options`\n\n| option      |  type  | default | description                                   |\n|-------------|--------|---------|:----------------------------------------------|\n| prefix      | string |  `\"\"`   | A string to prepend to all ids.               |\n| globalSlugs | bool   | `false`   | Track ids from one use of marked to the next. This ensures unique headers when parsing multiple markdown fragments and rendering the results as a single document. When set to false, the slugger and headers lists are cleared on every marked run.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkedjs%2Fmarked-gfm-heading-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkedjs%2Fmarked-gfm-heading-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkedjs%2Fmarked-gfm-heading-id/lists"}