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

Feat: New syntax highlight system based on shiki #1606

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

aegroto
Copy link
Contributor

@aegroto aegroto commented Nov 18, 2024

Description

I have implemented a novel code highlight widget based on Shiki, which authors claim to keep the bundle size small. Fixes #1242.

Screenshots

Light mode:

immagine

Dark mode:

immagine

Additional Context

I am undecided about which themes to adopt. The complete list is provided here.

Checklist

Are your changes backwards compatible? Please answer below: This removes any reference to react-syntax-highligher, replacing it with Shiki. However, I guess no working code depends on this.

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below: 8, I have manually tested with different languages and with no at all on both comments and posts, checking if the preview was updated as well.

For frontend changes: Tested on mobile, light and dark mode? Please answer below: Yes.

Did you introduce any new environment variables? If so, call them out explicitly here: No.

Copy link

socket-security bot commented Nov 18, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] None +43 1.06 MB kmck, wooorm
npm/[email protected] None +35 13 MB antfu, octref, orta, ...1 more

🚮 Removed packages: npm/[email protected]

View full report↗︎

Copy link

socket-security bot commented Nov 18, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Possible typosquat attack npm/[email protected] ⚠︎

View full report↗︎

Next steps

What is a typosquat?

Package name is similar to other popular packages and may not be the package you want.

Use care when consuming similarly named packages and ensure that you did not intend to consume a different package. Malicious packages often publish using similar names as existing popular packages.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

@aegroto aegroto marked this pull request as draft November 18, 2024 22:54
components/codeblock.js Outdated Show resolved Hide resolved
@aegroto
Copy link
Contributor Author

aegroto commented Nov 19, 2024

@huumn Thanks for your feedback. I have removed the dependency on directly setting the HTML.

I have also fixed a bug that blocked the adoption of darkMode. However, it looks like the useDarkMode hook is not triggering a re-render until the webpage is refreshed. Could you please check if my usage of the hook is incorrect? Otherwise there may be a bug preventing dark mode updates to be propagated through to the widgets.

@ekzyis
Copy link
Member

ekzyis commented Nov 19, 2024

The missing dark mode update was fixed in #1603

@aegroto
Copy link
Contributor Author

aegroto commented Nov 19, 2024

@ekzyis Thanks for your update, I have merged last changes to the master and I confirm dark mode switch works now! I believe the code is ready for review.

@aegroto aegroto marked this pull request as ready for review November 19, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syntax highlighting
3 participants