Closed tabuna closed 5 months ago
As a potential solution, could we add more selectors to specify the element?
We could. I'm not entirely against it. Although in my personal preference, more colors don't necessarily mean better readability. I based the initial token set on what I've been using and finetuning on my blog and in my IDE for years. I think it strikes a good balance.
However, adding tokens and more rules isn't all that difficult. We should consider breaking changes though. If we change the token of an existing keyword, that is a breaking change.
I'll keep this issue open, but I don't intend to work on it soon. I will reconsider it when we're working on a v2.
I'd just like to add my voice to this request. I'd love to migrate to this from Highlight.js but I can't unless I can achieve the same level of highlighting.
The concept of a native PHP highlighter is awesome, but I think it'll have very limited appeal if the colorization isn't on the same level of what the JS solutions offer (Highlight.js, Shiki etc.). It's just not the UI end-users are looking for in apps.
Given that I've added a bunch of features for v2, I've removed the v2 milestone from this issue. I still plan on looking into it for a future major version, but it's not high on my priority list. If someone want to put in the work, I'm happy to review and merge a PR.
Right now, I don't have any plans on adding new tokens. However, it's pretty trivial to add your own, I wrote a detailed guide on how to do it here: https://tempest.stitcher.io/highlight/03-adding-tokens
You may have noticed that the code lacks highlighting for various types of values, such as strings, numbers, and boolean constants. Unlike some libraries (for example, prismjs), where such highlighting is already implemented, in tempestphp, this does not happen, and as a result, values and the
return
operators are marked with the same style - as keywords.Here's an example of how prismjs marks:
To illustrate, let's take the following code:
In GitHub's syntax highlighting, we see that
return
andnull
are different in color. However, when using the library, this does not happen because both elements have the CSS selectorhl-keyword
. Example:As a potential solution, could we add more selectors to specify the element?