{"id":17096291,"url":"https://github.com/rehypejs/rehype-starry-night","last_synced_at":"2025-04-12T23:24:22.445Z","repository":{"id":246530786,"uuid":"821194380","full_name":"rehypejs/rehype-starry-night","owner":"rehypejs","description":"plugin to apply syntax highlighting to code with `starry-night`","archived":false,"fork":false,"pushed_at":"2024-10-11T13:33:11.000Z","size":50,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-05T12:46:05.568Z","etag":null,"topics":["highlight","html","plugin","rehype","rehype-plugin","starry-night","syntax","unified"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","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/rehypejs.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":"unifiedjs","open_collective":"unified"}},"created_at":"2024-06-28T02:43:57.000Z","updated_at":"2025-03-29T15:12:12.000Z","dependencies_parsed_at":"2024-06-28T14:39:11.293Z","dependency_job_id":null,"html_url":"https://github.com/rehypejs/rehype-starry-night","commit_stats":null,"previous_names":["rehypejs/rehype-starry-night"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-starry-night","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-starry-night/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-starry-night/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-starry-night/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rehypejs","download_url":"https://codeload.github.com/rehypejs/rehype-starry-night/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248644302,"owners_count":21138576,"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":["highlight","html","plugin","rehype","rehype-plugin","starry-night","syntax","unified"],"created_at":"2024-10-14T14:45:10.240Z","updated_at":"2025-04-12T23:24:22.415Z","avatar_url":"https://github.com/rehypejs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"readme":"# rehype-starry-night\n\n[![Build][badge-build-image]][badge-build-url]\n[![Coverage][badge-coverage-image]][badge-coverage-url]\n[![Downloads][badge-downloads-image]][badge-downloads-url]\n[![Size][badge-size-image]][badge-size-url]\n[![Sponsors][badge-sponsors-image]][badge-collective-url]\n[![Backers][badge-backers-image]][badge-collective-url]\n[![Chat][badge-chat-image]][badge-chat-url]\n\n**[rehype][github-rehype]** plugin to apply syntax highlighting to code with\n[`starry-night`][github-starry-night].\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When should I use this?](#when-should-i-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n  * [`Options`](#options)\n  * [`rehypeStarryNight(options) (default)`](#rehypestarrynightoptions-default)\n* [HTML](#html)\n* [CSS](#css)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Related](#related)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is a [unified][github-unified] ([rehype][github-rehype]) plugin to\nperform syntax highlighting.\nIt uses [`starry-night`][github-starry-night],\nwhich is a high quality highlighter that can support tons of grammars and\napproaches how GitHub renders code.\n\n## When should I use this?\n\nThis plugin is useful when you want to perform syntax highlighting in rehype.\nIf you are not using rehype,\nyou can instead use [`starry-night`][github-starry-night] directly.\n\nYou can combine this package with [`rehype-twoslash`][github-rehype-twoslash].\nThat processes JavaScript and TypeScript code with [`twoslash`][twoslash] and\nalso uses `starry-night` just for that code.\n\n`starry-night` has a WASM dependency,\nand rather big grammars,\nwhich means that this plugin might be too heavy particularly in browsers,\nin which case [`rehype-highlight`][github-rehype-highlight] might be more\nsuitable.\n\n## Install\n\nThis package is [ESM only][github-gist-esm].\nIn Node.js (version 16+), install with [npm][npm-install]:\n\n```sh\nnpm install rehype-starry-night\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport rehypeStarryNight from 'https://esm.sh/rehype-starry-night@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import rehypeStarryNight from 'https://esm.sh/rehype-starry-night@2?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\nSay we have the following file `example.md`:\n\n````markdown\n# Neptune\n\n```rs\nfn main() {\n    println!(\"Hello, Neptune!\");\n}\n```\n````\n\n…and our module `example.js` contains:\n\n```js\nimport rehypeStarryNight from 'rehype-starry-night'\nimport rehypeStringify from 'rehype-stringify'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport {read} from 'to-vfile'\nimport {unified} from 'unified'\n\nconst file = await read('example.md')\n\nawait unified()\n  .use(remarkParse)\n  .use(remarkRehype)\n  .use(rehypeStarryNight)\n  .use(rehypeStringify)\n  .process(file)\n\nconsole.log(String(file))\n```\n\n…then running `node example.js` yields:\n\n```html\n\u003ch1\u003eNeptune\u003c/h1\u003e\n\u003cpre\u003e\u003ccode class=\"language-rs\"\u003e\u003cspan class=\"pl-k\"\u003efn\u003c/span\u003e \u003cspan class=\"pl-en\"\u003emain\u003c/span\u003e() {\n    \u003cspan class=\"pl-en\"\u003eprintln!\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003eHello, Neptune!\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e);\n}\n\u003c/code\u003e\u003c/pre\u003e\n```\n\n## API\n\n### `Options`\n\nConfiguration for `rehype-starry-night`.\n\n###### Extends\n\n* `StarryNightOptions`\n\n###### Fields\n\n* `allowMissingScopes?` (`boolean | null | undefined`)\n  — do not warn for missing scopes (default: `false`)\n* `grammars?` (`ReadonlyArray\u003cGrammar\u003e | null | undefined`)\n  — grammars to support (default: `common`)\n* `plainText?` (`ReadonlyArray\u003cstring\u003e | null | undefined`)\n  — list of language names to not highlight (default: `[]`)\n\n### `rehypeStarryNight(options) (default)`\n\nPlugin to highlight code with `starry-night`.\n\n###### Parameters\n\n* `options?` (`Readonly\u003cOptions\u003e | null | undefined`)\n  — configuration (optional)\n\n###### Returns\n\nTransform (`(tree: Root, file: VFile) =\u003e Promise\u003cRoot\u003e`).\n\n## HTML\n\nOn the input side,\nthis plugin looks for code blocks with a `language-*` class.\n\nOn the output side,\nthis plugin generates `span` elements with classes that can be enhanced with\nCSS.\n\n## CSS\n\nSee [“CSS” in `starry-night`][github-starry-night-css] for more info.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `rehype-starry-night@2`,\ncompatible with Node.js 16.\n\n## Security\n\nThis package is safe.\n\n## Related\n\n* [`rehype-highlight`][github-rehype-highlight]\n  — highlight code blocks with `lowlight`\n* [`rehype-twoslash`][github-rehype-twoslash]\n  — process JavaScript/TypeScript code with `twoslash` and `starry-night` too\n\n## Contribute\n\nSee [`contributing.md`][health-contributing] in [`rehypejs/.github`][health]\nfor ways to get started.\nSee [`support.md`][health-support] for ways to get help.\n\nThis project has a [code of conduct][health-coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][file-license] © [Julien Barbay][github-y-nk]\n\n\u003c!-- Definitions --\u003e\n\n[badge-backers-image]: https://opencollective.com/unified/backers/badge.svg\n\n[badge-build-image]: https://github.com/rehypejs/rehype-starry-night/actions/workflows/main.yml/badge.svg\n\n[badge-build-url]: https://github.com/rehypejs/rehype-starry-night/actions\n\n[badge-collective-url]: https://opencollective.com/unified\n\n[badge-coverage-image]: https://img.shields.io/codecov/c/github/rehypejs/rehype-starry-night.svg\n\n[badge-coverage-url]: https://codecov.io/github/rehypejs/rehype-starry-night\n\n[badge-downloads-image]: https://img.shields.io/npm/dm/rehype-starry-night.svg\n\n[badge-downloads-url]: https://www.npmjs.com/package/rehype-starry-night\n\n[badge-size-image]: https://img.shields.io/bundlejs/size/rehype-starry-night\n\n[badge-size-url]: https://bundlejs.com/?q=rehype-starry-night\n\n[badge-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg\n\n[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[badge-chat-url]: https://github.com/rehypejs/rehype/discussions\n\n[esmsh]: https://esm.sh\n\n[file-license]: license\n\n[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[github-rehype]: https://github.com/rehypejs/rehype\n\n[github-rehype-highlight]: https://github.com/rehypejs/rehype-highlight\n\n[github-rehype-twoslash]: https://github.com/rehypejs/rehype-twoslash\n\n[github-starry-night]: https://github.com/wooorm/starry-night\n\n[github-starry-night-css]: https://github.com/wooorm/starry-night#css\n\n[github-unified]: https://github.com/unifiedjs/unified\n\n[github-y-nk]: https://github.com/y-nk\n\n[health-coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md\n\n[health-contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md\n\n[health-support]: https://github.com/rehypejs/.github/blob/main/support.md\n\n[health]: https://github.com/rehypejs/.github\n\n[npm-install]: https://docs.npmjs.com/cli/install\n\n[twoslash]: https://twoslash.netlify.app\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehypejs%2Frehype-starry-night","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frehypejs%2Frehype-starry-night","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehypejs%2Frehype-starry-night/lists"}