{"id":22799057,"url":"https://github.com/thomd/remark-heading-lines","last_synced_at":"2026-02-06T09:35:14.075Z","repository":{"id":245106297,"uuid":"801233958","full_name":"thomd/remark-heading-lines","owner":"thomd","description":"remark plugin to add a link to a headline containing start- and end-lines of a heading section","archived":false,"fork":false,"pushed_at":"2024-11-16T17:44:05.000Z","size":123,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-29T06:17:58.841Z","etag":null,"topics":["ast","markdown","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/thomd.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":"2024-05-15T20:52:36.000Z","updated_at":"2024-11-16T17:44:09.000Z","dependencies_parsed_at":"2025-02-05T21:36:31.483Z","dependency_job_id":"7be95029-2f1b-4ea8-a831-bbb0243ddca6","html_url":"https://github.com/thomd/remark-heading-lines","commit_stats":null,"previous_names":["thomd/remark-headline-ranges","thomd/remark-headline-edit","thomd/remark-heading-lines"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thomd/remark-heading-lines","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomd%2Fremark-heading-lines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomd%2Fremark-heading-lines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomd%2Fremark-heading-lines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomd%2Fremark-heading-lines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomd","download_url":"https://codeload.github.com/thomd/remark-heading-lines/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomd%2Fremark-heading-lines/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29157426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T07:18:23.844Z","status":"ssl_error","status_checked_at":"2026-02-06T07:13:32.659Z","response_time":59,"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":["ast","markdown","remark","remark-plugin"],"created_at":"2024-12-12T07:07:49.095Z","updated_at":"2026-02-06T09:35:14.058Z","avatar_url":"https://github.com/thomd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# remark-heading-lines\n\n![Build][build-badge]\n\n`remark-heading-lines` is a [remark][remark] plugin which adds a link at a headline containing the **start-** and **end-line** of a headline section respecting its hierarchy. The lines refer to the source markdown file.\n\nAn exemplary usecase for this plugin is to generate **wikipedia**-like **edit** links beside headlines (see the example below).\n\n## Usage\n\nSay we have the following file `example.md`:\n\n```markdown\n# Level 1\n\nparagraph\n\n## Level 2\n\nparagraph\n\n### Level 3\n\nparagraph\n\n## Level 2\n\nparagraph\n\n# Level 1\n\nparagraph\n```\n\nand a module `example.js`:\n\n```js\nimport { remark } from 'remark'\nimport remarkHeadingLines from 'remark-heading-lines'\nimport remarkRehype from 'remark-rehype'\nimport rehypeStringify from 'rehype-stringify'\nimport { read } from 'to-vfile'\n\nconst file = await remark()\n    .use(remarkHeadingLines, {\n        position: 'after',\n        maxDepth: 2,\n        urlPattern: 'edit?line={start}-{end}',\n        linkText: 'edit',\n        className: 'h{depth}'\n    })\n    .use(remarkRehype)\n    .use(rehypeStringify)\n    .process(await read('example.md'))\n\nconsole.log(file.value)\n```\n\nthen running `node example.js` yields:\n\n```html\n\u003cdiv class=\"h1\"\u003e\u003ch1\u003eLevel 1\u003c/h1\u003e\u003ca href=\"edit?line=1-16\"\u003eedit\u003c/a\u003e\u003c/div\u003e\n\u003cp\u003eparagraph\u003c/p\u003e\n\u003cdiv class=\"h2\"\u003e\u003ch2\u003eLevel 2\u003c/h2\u003e\u003ca href=\"edit?line=5-12\"\u003eedit\u003c/a\u003e\u003c/div\u003e\n\u003cp\u003eparagraph\u003c/p\u003e\n\u003ch3\u003eLevel 3\u003c/h3\u003e\n\u003cp\u003eparagraph\u003c/p\u003e\n\u003cdiv class=\"h2\"\u003e\u003ch2\u003eLevel 2\u003c/h2\u003e\u003ca href=\"edit?line=13-16\"\u003eedit\u003c/a\u003e\u003c/div\u003e\n\u003cp\u003eparagraph\u003c/p\u003e\n\u003cdiv class=\"h1\"\u003e\u003ch1\u003eLevel 1\u003c/h1\u003e\u003ca href=\"edit?line=17-19\"\u003eedit\u003c/a\u003e\u003c/div\u003e\n\u003cp\u003eparagraph\u003c/p\u003e\n```\n\n## Use with remark-CLI\n\n```bash\nnpm install remark-cli\nremark example.md --use remark-heading-lines\nremark example.md --use remark-heading-lines --use remark-rehype -use rehype-stringify\n```\n\n## API\n\nThe default export is `remarkHeadingLines`.\n\n```js\nunified().use(remarkHeadingLines[, options])\n```\n\n### Options\n\n* `position` (`string`, optional) — position of the link relative to the headline. Possible values are `append` (put link inside `h`-tag at last index), `prepend` (put link inside `h`-tag at first index), `after` (put link after the `h`-tag) and `before` (put link before the `h`-tag). The `after` and `before` positions are wrapped in a `div` tag and require `remark-rehype`. Default is `append`.\n\n* `maxDepth` (`integer`, optional) — maximum depth of headline hierarchy to render links. Default value is `6`.\n\n* `urlPattern` (`string`, optional) — pattern to generate the link. Placeholders are `{start}` and `{end}`. Default pattern is `edit/{start}/{end}`.\n\n* `linkText` (`string`, optional) — text used for the link. Default text is `Edit`.\n\n* `className` (`string`, optional) — style class to be added to the `div` wrapper when using position `after` or `before`. Placeholder is `{depth}`. Default is no style class.\n\n[remark]: https://github.com/remarkjs/remark\n[build-badge]: https://github.com/thomd/remark-heading-lines/workflows/plugin-test/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomd%2Fremark-heading-lines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomd%2Fremark-heading-lines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomd%2Fremark-heading-lines/lists"}