JSPM

rehype-starry-night

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3028
  • Score
    100M100P100Q131690F
  • License MIT

syntaxhighlight using starry-night

Package Exports

  • rehype-starry-night
  • rehype-starry-night/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rehype-starry-night) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

rehype-starry-night

What is it?

It's a rehype plugin to transform <code> blocks with language attribute with @wooorm's starry-night code syntax highlighter.

You may want to try this if you were unhappy with results from prism or shiki.

How to use?

  1. Install the plugin with npm (npm install rehype-starry-night)
  2. Use in a unified pipeline like this:
import fs from 'node:fs/promises'
import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
import rehypeStarryNight from 'rehype-starry-night'

const file = await unified()
  .use(remarkParse)
  .use(remarkRehype)
  .use(rehypeStarryNight)
  .use(rehypeStringify)
  .process(await fs.readFile('example.md'))

console.log(String(file))

Configure?

The options you can pass are the same as the original project, which you can find here.

Since most of the time this plugin will be used in a larger context which involves pre-processing of markdown, i took the freedom to default grammars to all which means all languages should be supported out of the box. There's no extra cost at install since this all is brought by starry night, and should not impact performance as long as you don't run this in the browser.