-
Notifications
You must be signed in to change notification settings - Fork 0
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
perf: Remove HTML parsing, instead sanitize and set dangerously #521
Draft
AVGVSTVS96
wants to merge
16
commits into
customThemeShiki
Choose a base branch
from
customThemeShikiPerformance
base: customThemeShiki
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Create `shikiTransformers.ts` with `removeTabIndexFromPre` transformer - Passes `node` prop to `pre()` transformer hook to set the tabindex to -1 on shiki generated pre elements
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
a52bbb9
to
1ea2c19
Compare
93095bd
to
d6da82e
Compare
fdee84e
to
fef7127
Compare
d6da82e
to
20bb6ef
Compare
Create a hook to highlight code using custom theme and a highlighter created with that custom theme
fef7127
to
9794f7a
Compare
0fa056b
to
b2dd1b5
Compare
b02b48a
to
b618f9e
Compare
b618f9e
to
46bebe1
Compare
04272be
to
482374e
Compare
482374e
to
a2b538c
Compare
69822e9
to
df6a518
Compare
df6a518
to
bd71619
Compare
bd71619
to
d9edfc5
Compare
Add optional debouncing when debouncMs is passed to hook Set 150ms in CodeHighlight for testing
Parsing HTML to React elements is a performance bottleneck which slows down code block rendering. This change removes the parsing and instead sanitizes the HTML with DOMPurify, and sets it with `dangerouslySetInnerHTML` Also, this HTML processing logic is moved from `CodeHighlight` to `useShiki`, this way the hook always returns sanitized HTML, and logic is centralized.
b2dd1b5
to
7db85ab
Compare
1fd7bf4
to
8423cae
Compare
This was referenced Jan 28, 2025
46b30c5
to
9a0d291
Compare
4d0067e
to
ba7ae7a
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Parsing HTML to React elements is a performance bottleneck which slows down code block rendering. This change removes the parsing and instead sanitizes the HTML with DOMPurify, and sets it with
dangerouslySetInnerHTML
Also, this HTML processing logic is moved from
CodeHighlight
touseShiki
, this way the hook always returns sanitized HTML, and logic is centralized.