-
-
Notifications
You must be signed in to change notification settings - Fork 130
Feature - optimise build size and performance with PrismLight syntax highlighter and add a new highlighter style selector #97
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
Conversation
✅ Deploy Preview for quicksnip ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@psychlone77 @saminjay This PR handles (and tests) the usage of PrismLight
to reduce the build size, and from what I can see while testing this appears to function exactly as before.
A new highlighter style selector has been added, but this is only proof of concept for now and is therefore subject to change. I've also done some consolidation to remove duplicated code around theme selection ("dark" or "light"), and selector component logic.
Finally, the selected highlighter theme is saved in localStorage, as well as the language (but the latter of these two changes may not be desirable), so that these selections persist for the user in the same manner as the theme.
The feature discussion for these changes is here: #94, and everything is subject to change if these alterations are not welcome. Thanks.
It doesn't seem to highlight certain language like C or CPP
It doesn't seem to highlight certain language like C or CPP
I just checked and it was working for me on 2 randomly selected styles for c
and cpp
. Was there a particular style that didn't work for you?
"coyWithoutShadows" style:
Screenshot 2025年01月02日 at 12 19 35
"pojoaque" style:
Screenshot 2025年01月02日 at 12 20 04
What style had been selected in the highlight style selector?
oneDark
But i checked a couple more, and none color the text
That is very strange. All of the selections seem to be working for me. This is with oneDark
selected:
I will look into this further, but can you confirm you've pulled the latest code and try removing your node_modules and re-installing with npm ci
?
I'm using the preview that's available here on your PR
image
It deploys your latest commit as a preview
I'm using the preview that's available here on your PR image It deploys your latest commit as a preview
Apologies, I thought you were testing locally. I've also tried on the deploy and confirmed it is also working there for me:
Screenshot 2025年01月02日 at 13 01 33Ddi you try clearing browser cache?
Didn't mean to close. Re-opened.
I've tested it one brave, chrome, firefox, all with and without extension and it didn't work on a signe one of them... I think there is something wrong with this...
Here is another test with a different highlighter style on the deploy:
Screenshot 2025年01月02日 at 13 03 25But on the screen you are providing it's not working...
currently on prod we have this:
image
Not just a background + text color, but proper syntax highlight
But on the screen you are providing it's not working... currently on prod we have this: image Not just a background + text color, but proper syntax highlight
Ok I understand what you mean now. I will look into this.
@Mathys-Gasnier I think i've fixed it. It seems that PrismLight
is not suitable for our use case as a lot of the languages are discounted. This was hidden on my local as it was cached. However, this does mean that the build size cannot be reduced:
Sad, but i think that size is for good, since it allows for snippets to be read easier.
Unfortunately it seems that way. Although the original premise of this PR is now redundant, I am interested to see if you and the other maintainers (+ the community) would find the other changes here useful.
The theme switch is cool, but i don't really think it's necessary, and for the Select, I think another PR was created that migrates that to Shadcn and tailwind
The Select component code remains the same (apart from some minor changes that handle text overflow with ellipsis), but it was just extracted into its own component. In that case I can close this PR if you are happy for me to do so?
@barrymun, regarding the theme switch, we might come back to it in the future. But right now, I also agree with @Mathys-Gasnier. It's better to keep things simple.
Uh oh!
There was an error while loading. Please reload this page.
Description
(削除) Optimise build size and performance withPrismLight
syntax highlighter. (削除ここまで)PrismLight
cannot be used as it does not support a lot of the languages that are selectable in the dropdown.theme
andtoggleTheme
so that duplicated logic is removed.Selector
component.localStorage
("languageName").localStorage
("highlighterStyleName").Type of Change
(削除) Performance optimisations (削除ここまで)and adding a new selector.Checklist
Related Issues
Closes #94
Additional Context
Screenshots (Optional)
Click to view screenshots
new build size:
Screenshot 2025年01月01日 at 17 14 25
new
localStorage
keys:Screenshot 2025年01月01日 at 18 50 06