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

[Feature] - Use PrismLight syntax highlighting instead of Prism to improve performance and reduce build size #94

Closed
barrymun opened this issue Jan 1, 2025 · 5 comments

Comments

@barrymun
Copy link
Contributor

barrymun commented Jan 1, 2025

What feature would you like to see?

Import PrismLight instead of Prism when using the react-syntax-highlighter lib. Suggested here.

This should improve performance and reduce the build size.

It is important to ensure that all functionality remains the same.

@barrymun
Copy link
Contributor Author

barrymun commented Jan 1, 2025

WIP

@barrymun
Copy link
Contributor Author

barrymun commented Jan 1, 2025

@dostonnabotov Whilst working in this area I noticed that we don't allow the user to change the style of the syntax highlighter itself. We have the code style={theme === "dark" ? oneDark : oneLight} which toggles between light and dark for the "one" style depending on the theme.

I was wondering if adding the ability to select the style of the highlighter theme was something we wish to add?

Here is how I would envisage such a feature:

  1. A new selector somewhere on the page (placed at the top for the purposes of this demo)
    Screenshot 2025-01-01 at 16 04 37

  2. The dropdown options (taken from react-syntax-highlighter/dist/esm/styles/prism):
    Screenshot 2025-01-01 at 16 06 28

  3. Difference snippet styles:
    Screenshot 2025-01-01 at 16 07 10
    Screenshot 2025-01-01 at 16 07 26
    Screenshot 2025-01-01 at 16 07 44
    Screenshot 2025-01-01 at 16 08 08

Please let me know if you think this is something worth pursuing, thanks.

@dostonnabotov
Copy link
Owner

dostonnabotov commented Jan 1, 2025

Hey, @barrymun. Thank you for taking the time to contribute to our project.

I briefly talked about not adding code preview theme toggle to keep the simplicity in this issue #66.

However, if community wants to see this feature being included, why not? Perhaps instead of highlighting just the code, we can update the theme of the whole website to match the code theme.

I love to hear others' thoughts on this as well.

@barrymun
Copy link
Contributor Author

barrymun commented Jan 1, 2025

@dostonnabotov Thanks for linking that issue. I've created a draft PR (which builds on #73 ) if you want to try out a sample version of what this could look like in its basic form. The suggestion whereby we update not only the style of the code but also the entire app could be a good one. Here is the related PR: #97.

@barrymun barrymun changed the title [Feature] - Use PrsimLight syntax highlighting instead of Prism to improve performance and reduce build size [Feature] - Use PrismLight syntax highlighting instead of Prism to improve performance and reduce build size Jan 1, 2025
@barrymun
Copy link
Contributor Author

barrymun commented Jan 2, 2025

PrismLight is not suitable as a number of languages (like c, c++, etc.) are only supported by the full library. Closing.

@barrymun barrymun closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants