wooorm / starry-night

Syntax highlighting, like GitHub
MIT License
1.46k stars 31 forks source link

Is it possible to expand the list of scopes->classes? #18

Closed DeeeeLAN closed 1 year ago

DeeeeLAN commented 1 year ago

The systemverilog language has a lot of scope options (https://github.com/wooorm/starry-night/blob/main/lang/source.systemverilog.js)

It appears a lot of them are getting flattened when classes are applied. Things like storage types (storage-type-systemverilog) and keywords for marking modules/classes/functions all get grouped under the keyword class. I would be interested in overriding the conversion somehow so I can make more granular classes and have more control over how the code is highlighted.

Is there an official way to do this? If not, am not opposed to forking the repository and locally modifying what I need if it is relatively straightforward to do.

wooorm commented 1 year ago

Flattening is intended.

Do you have an example that looks different on GitHub than it does with starry-night? This project matches GitHub. If you don‘t want to match GitHub, you don’t need this project, vscode-textmate can be used.

DeeeeLAN commented 1 year ago

I see, that makes sense. Do you know of any existing remark/rehype extensions for vscode-textmate? Or would I be writing one myself? I am not sure how complicated that is.

wooorm commented 1 year ago

It's not super complicated. But it isn't very easy either.

VSCode is made for spitting out colors, font-styles. So you must pass it a theme, that matches all the styles you want to show. Then you can add grammars. This works fine with more client-side appy things, not so much with normal css and dark/light/etc preferences.

GitHub has one theme, with some good color varieties. And they basically have a full time person maintaining a registry of 700 grammars.

Other than folks wanting to match gh because it's big and omnipresent, it's just the easiest to go with something that's super well maintained. I don't have the bandwidth to maintain 700 grammars or arbitrary themes.

DeeeeLAN commented 1 year ago

That makes sense. Since I will primarily be using one or two languages mostly and only in a blog post style, it is easier for me to add coloring as I go as long as I get good class names matching the grammar. That's why I was thinking it might be simple enough to just fork starry night and loosen the grammar to classname conversion, since it is already built to do everything I want. But I will look into creating a similar tool using the vscode package as a base.