Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glow syntax highlighter support #1358

Open
asm0dey opened this issue Feb 29, 2024 · 2 comments
Open

Glow syntax highlighter support #1358

asm0dey opened this issue Feb 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@asm0dey
Copy link

asm0dey commented Feb 29, 2024

Is your feature request related to a problem? Please describe.

There are several features I miss in shiki while creating presentations with slides

  1. Highlight separate tokens (usually words)
  2. Highlight errors

Describe the solution you'd like

There is a new player in the field of markdown highlighters: glow. It supports these features and many languages.

As far as I can see current solutions only support line highlighting

@asm0dey asm0dey added the enhancement New feature or request label Feb 29, 2024
@antfu
Copy link
Member

antfu commented Mar 2, 2024

Good to know, Glow - thanks for introducing it!

First, to your desired features:

Highlight separate tokens (usually words)

You could, Shiki has a very powerful transformer API - for example: https://shiki.style/packages/transformers#transformernotationwordhighlight

Highlight errors

You could do it as well. Probably much more powerful than Glow as far as I see:

While tbh, they both has certain complexity to set up, it would be actually an integration issue about how we could find a easy way to configure and animate with the clicks system etc. But I also see there shouldn't be any blocker preventing you from doing it on the userland today as Slidev exposes the transformer configs: https://sli.dev/custom/highlighters#configure-shiki (just might not be very easy)


About Glow - while at first glance it seems to be a good idea, after digging in - it doesn't seem to be a very solid solution (https://github.com/nuejs/nue/blob/master/packages/glow/src/glow.js) - it's a hard-coded regex-based solution. This provides rather a rough highlighting result, which to me, fall into the similar category as Prism.js. But as it seems to be more lightweight and modern than Prism, I don't mind to actually support it as long as the integration and maintenance do not take too much effort. But as this is still an integration problem, I don't think word and errors highlight would just work especially if you want to have some animations around them or so.

@asm0dey
Copy link
Author

asm0dey commented Mar 2, 2024

@antfu thanks a lot for the meaningful answer! I have to agree with your points, it seems this feature should be closed/deprioritized and another one, for "more interesting" highlights, should be created. On it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants