wooorm / starry-night

Syntax highlighting, like GitHub
MIT License
1.45k stars 30 forks source link

Rehype/Remark Plugin? #1

Closed eligundry closed 2 years ago

eligundry commented 2 years ago

This looks great! I'd love to use it with a static site generator. Do you have any plans for a Remark/Rehype plugin wrapping this or would that be fair game for the community?

wooorm commented 2 years ago

Hey! It’s sort of up for grabs. And also waiting on getting this package actually published, which should be done by the end of the day. If you want to maintain it, please do! I wasn’t planning on making one very soon.

With so many highlighters, I feel like there should perhaps be an abstraction in the middle, instead of everyone reinventing the wheel every time?

Here’s how I’d do it, off the top of my head (so there might be bugs!). Maybe I should add that to the docs?:

EDIT: see the plugin in the readme https://github.com/wooorm/starry-night#example-integrate-with-unified-remark-and-rehype.

wooorm commented 2 years ago

Fixed the plugin above to make sure it works properly, and added it and an example to the readme!

eligundry commented 2 years ago

Thanks @wooorm! I'll look into adapting the code above into a plugin once this is on npm + I have time.

wooorm commented 2 years ago

Closing for now. There’s a plugin documented in the readme. If anyone wants to maintain it themselves or even say make a PR to replace lowlight with this in rehype-highlight, :+1:

naiyerasif commented 2 years ago

I have a Remark plugin here in case someone is interested: https://github.com/Microflash/remark-starry-night

stefanprobst commented 2 years ago

note that the example above wraps with a <pre>, not <pre><code> - which is what github code blocks do as well, but is different from what many other highlighters generate i think

wooorm commented 2 years ago

You are right. I fixed that in the readme. I’ll replace the code blocks above with a link to that.