{"id":15042825,"url":"https://github.com/sindresorhus/remark-custom-header-id","last_synced_at":"2025-10-25T05:47:29.040Z","repository":{"id":227017098,"uuid":"770212480","full_name":"sindresorhus/remark-custom-header-id","owner":"sindresorhus","description":"Remark plugin for adding a custom ID attribute to Markdown headers","archived":false,"fork":false,"pushed_at":"2024-05-28T17:45:36.000Z","size":7,"stargazers_count":36,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T15:24:37.855Z","etag":null,"topics":["markdown","nodejs","npm","remark","remark-plugin"],"latest_commit_sha":null,"homepage":"","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/sindresorhus.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":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2024-03-11T06:32:42.000Z","updated_at":"2025-01-14T23:18:11.000Z","dependencies_parsed_at":"2024-03-11T06:44:27.971Z","dependency_job_id":"8d9664e6-d069-463b-aa9f-b3698886b210","html_url":"https://github.com/sindresorhus/remark-custom-header-id","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":"0.19999999999999996","last_synced_commit":"4bd527187f42a3d13672a04b041f6d00fcbdcee0"},"previous_names":["sindresorhus/remark-custom-header-id"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fremark-custom-header-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fremark-custom-header-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fremark-custom-header-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fremark-custom-header-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/remark-custom-header-id/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237188481,"owners_count":19269140,"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":["markdown","nodejs","npm","remark","remark-plugin"],"created_at":"2024-09-24T20:48:03.224Z","updated_at":"2025-10-19T19:31:12.609Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":[],"sub_categories":[],"readme":"# remark-custom-header-id\n\n\u003e [Remark](https://github.com/remarkjs/remark) plugin for adding a custom ID attribute to Markdown headers\n\nThis allows for stable and more meaningful anchor links in your generated HTML.\n\n## Install\n\n```sh\nnpm install remark-custom-header-id\n```\n\n## Usage\n\n### Remark\n\n```js\nimport {remark} from 'remark';\nimport remarkRehype from 'remark-rehype';\nimport rehypeStringify from 'rehype-stringify';\nimport remarkCustomHeaderId from 'remark-custom-header-id';\n\nconst file = await remark()\n\t.use(remarkCustomHeaderId)\n\t.use(remarkRehype) // Markdown to HTML\n\t.use(rehypeStringify) // Stringify the HTML\n\t.process('# Foo {#custom-id}');\n\nconsole.log(String(file));\n//=\u003e '\u003ch1 id=\"custom-id\"\u003eFoo\u003c/h1\u003e'\n```\n\n### Astro\n\n```js\n// astro.config.js\nimport remarkCustomHeaderId from 'remark-custom-header-id';\n\nexport default defineConfig({\n\t// …\n\tmarkdown: {\n\t\tremarkPlugins: [\n\t\t\tremarkCustomHeaderId,\n\t\t],\n\t},\n\t// …\n});\n```\n\n### Alternative syntax for MDX files\n\nThe `{#custom-id}` notation does not work in [MDX](https://mdxjs.com) files because MDX treats `{}` as JSX syntax, causing a parsing error. \n\nYou can use one of these alternatives:\n\n- Escape curly braces: `\\{#custom-id\\}`\n- Use this syntax: `||custom-id||`\n\nExamples:\n\n- `## Some header \\{#custom-id\\}`\n- `## Some header ||custom-id||`\n\n## API\n\n### remarkCustomHeaderId()\n\nReturns a transformer function to be used with Remark.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fremark-custom-header-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fremark-custom-header-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fremark-custom-header-id/lists"}