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
feat: syntax tokens #57
base: main
Are you sure you want to change the base?
Conversation
❌ Deploy Preview for red-hat-design-tokens failed.
|
539049f
to
80c300a
Compare
|
OK @coreyvickery this is ready for you to tinker with. To get set up, check out this branch Then clean out your working directory (save any uncommitted changes, they may be deleted) Next install dependencies Then start the 11ty dev server Once that's ready, you can change the values in You can uncomment any of the commented tokens and add values to see how they will reflect on the page. You can add markdown fenced code blocks to |
80c300a
to
d4333d5
Compare
|
@marionnegp Tagging you to take over. |
|
@bennypowers, I've been trying to match up the Prism JS tokens with the XD mockups, and I'm wondering how Prism is matching tokens to pieces of the code. For example, in the screenshot below Is there a way to change this (maybe using Prism's Custom Class plugin)? Would that be a lot to manage in the future? |
|
@marionnegp if i understood correctly, you mean we should customize prism's parser to highlight tokens that it doesn't already, or to highlight them differently. If we went that route, we'd have to then also require all our users to implement a custom version of prism's parser whenever using our tokens, in order to get consistent results, and I think that's prohibitively complex for a user that just wants to theme a syntax snippet. we could try highlighting with highlight.js instead, which is also quite popular. |
|
@bennypowers, yeah, that level of complexity was what I was afraid of. I think we should try highlight.js instead. @coreyvickery had used the highlight.js demos as a guide and tweaked the color, so it should be easier to update token colors. |
|
|
@bennypowers, could you add highlight.js here instead of Prism.js? Does it cause any issues to use Prism in PFE and Highlight here? |
|
prism is the default in 11ty, but we can override that for the sake of the token pages, which I've done in the most recent commits. This is getting at a deeper problem which is that we should prefer not to tie our token names to a given library. So let's say we got things worked out using highlight JS, and using their token names in our token names. What if we get a request for prism.js support? treesitter? vscode? |
|
The current state of the PR encodes our color token names using highlightjs' syntax token names. The result is that the DP (as of 3c5a412) looks more-or-less like the XD, but this will be difficult to maintain and port to other syntax highlighting schemes like vscode, treesitter, or prism (which is the default highlighter for 11ty) I think the way forward is:
For reference, here are the highlight groups that nvim treesitter uses |
|
leaving this here for future reference: https://dbanks.design/blog/vs-code-theme-with-style-dictionary/#Syntax-styles |
|
I used this syntax highlighting spreadsheet to match Tree-sitter tokens to what we have in this XD as best as I could. If I wasn't sure whether there was any code from the XD mockup that matched, I left a @bennypowers, I can try installing Tree-sitter and working to add these if that would be the next step. |
|
@marionnegp I resolved the conflicts in this branch. b60bf62 looks nice! Build fails for good reasons: we need to realign syntax greys to the new grey tokens |
|
Update on syntax highlighting colors posted here. |

based on #55
closes #16