{"id":19894026,"url":"https://github.com/enpitsulin/rehype-prism-diff","last_synced_at":"2026-05-10T21:48:31.974Z","repository":{"id":53577023,"uuid":"481819901","full_name":"enpitsuLin/rehype-prism-diff","owner":"enpitsuLin","description":"A rehypre plugin allow not only diff language but also all language to show github flavored highlight diff block","archived":false,"fork":false,"pushed_at":"2022-08-11T03:24:24.000Z","size":293,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T05:28:51.275Z","etag":null,"topics":["diff","gfm","prismjs","refractor","rehype-plugin"],"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/enpitsuLin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-15T03:04:26.000Z","updated_at":"2023-09-26T23:43:25.000Z","dependencies_parsed_at":"2022-08-13T02:40:55.917Z","dependency_job_id":null,"html_url":"https://github.com/enpitsuLin/rehype-prism-diff","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/enpitsuLin/rehype-prism-diff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enpitsuLin%2Frehype-prism-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enpitsuLin%2Frehype-prism-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enpitsuLin%2Frehype-prism-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enpitsuLin%2Frehype-prism-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enpitsuLin","download_url":"https://codeload.github.com/enpitsuLin/rehype-prism-diff/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enpitsuLin%2Frehype-prism-diff/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32873150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"ssl_error","status_checked_at":"2026-05-10T13:40:02.145Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["diff","gfm","prismjs","refractor","rehype-plugin"],"created_at":"2024-11-12T18:32:17.374Z","updated_at":"2026-05-10T21:48:31.951Z","avatar_url":"https://github.com/enpitsuLin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rehypre-prism-diff\n\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n\nA rehypre plugin allow not only `diff` language but also all language to show github flavored highlight diff block, suport both [rehype-prism-plus](https://github.com/timlrx/rehype-prism-plus) and [rehype-prism](https://github.com/mapbox/rehype-prism)\n\n![sample](https://user-images.githubusercontent.com/29378026/163522813-e0466685-7075-4075-9530-3abd2c885b13.png)\n\n## Installation\n\nThis package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). In Node.js(version 12.20+, 14.14+,or 16.0+), install with npm:\n\n```sh\nnpm install rehype-prism-diff\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport RehypePrismDiff from 'https://esm.sh/rehype-prism-diff@1.1.0'\n```\n\n## Usage\n\nuse this package [as a rehype plugin.](https://github.com/rehypejs/rehype/blob/master/doc/plugins.md#using-plugins)\n\n## Options\n\n```typescript\nexport interface Options {\n  /** remove the first character which used to mark */\n  remove?: boolean\n  classMapping?: Partial\u003cRecord\u003c'diff' | 'deleted' | 'inserted' | 'warn' | 'comment', string | string[]\u003e\u003e\n}\n```\n\n**`options.remove`**\n\n`boolean`, default `false` - enable remove the first character which used to mark.\n\n**`options.classMapping`**\n\n`Record\u003c'diff' | 'deleted' | 'inserted' | 'warn' | 'comment', string|string[]\u003e` - custom className mapping.\nproperties:\n\n- diff: the className which be added to `code` element.\n- deleted\\inserted\\warn\\comment: the className which be added to corresponding marked `span.code-line` element\n\n## Styling\n\nThis plugin will add class `code-diff` to `code` element and add the corresponding class for each `span.code-line` element according to the first character of each line by default option.\n\nSo you should add stylesheet by yourself, for example:\n\n```css\n.code-line.diff-inserted {\n  background-color: rgba(16, 185, 129, 0.2); /* Set inserted line (+) color */\n}\n\n.code-line.diff-deleted {\n  background-color: rgba(239, 68, 68, 0.2); /* Set deleted line (-) color */\n}\n\n.code-line.diff-warn {\n  background-color: rgba(104, 45, 15, 0.2); /* Set warn line (!) color */\n}\n\n.code-line.diff-comment {\n  background-color: rgba(255, 255, 255, 0.2); /* Set comment line (#) color */\n}\n```\n\n**Notice**: if you config `classMapping` option, you need customize the css file accordingly.\n\n\u003c/details\u003e\n\n## Related\n\n- [rehype-prism](https://github.com/mapbox/rehype-prism) - syntax highlighting with Prism via refractor\n- [rehype-prism-plus](https://github.com/timlrx/rehype-prism-plus) - syntax highlighting with Prism via refractor with extras\n\n## Contribute\n\nIf you have any suggestion or bug, please feel free to [open an issue](https://github.com/enpitsuLin/rehype-prism-diff/issues/new)\n\n## License\n\nMIT © [enpitsuLin](https://enpitsulin.xyz)\n\n\u003c!-- Definitions --\u003e\n\n[coverage-badge]: https://codecov.io/gh/enpitsuLin/rehype-prism-diff/branch/master/graph/badge.svg\n[coverage]: https://codecov.io/gh/enpitsuLin/rehype-prism-diff\n[downloads-badge]: https://img.shields.io/npm/dm/rehype-prism-diff.svg\n[downloads]: https://www.npmjs.com/package/rehype-prism-diff\n[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-prism-diff.svg\n[size]: https://bundlephobia.com/result?p=rehype-prism-diff\n[esmsh]: https://esm.sh\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenpitsulin%2Frehype-prism-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenpitsulin%2Frehype-prism-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenpitsulin%2Frehype-prism-diff/lists"}