-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Refactor createShikiHighlighter #11825
Conversation
🦋 Changeset detectedLatest commit: 65bb472 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a major
changeset. A reviewer will merge this at the next release if approved.
base branch is next (still awaiting docs review before merging)
// We just generated this node, so any positional information is invalid. | ||
removePosition(replacement); | ||
} else { | ||
replacement = result.children[0] as Element; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this cast safe? we know there's at least 1 child and its an Element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it should be. We currently control this function (it's mostly internal details for Shiki only), so if it changes we can also tweak this here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just the one thing to confirm, otherwise lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a major
changeset. A reviewer will merge this at the next release if approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bluwy ! Just made some suggestions for your consideration that try to highlight more when someone might encounter the problem, because Shiki is pretty commonly used, but maybe transformers not quite as much! So something like this makes it maybe more obvious when someone needs to care and pay attention.
Co-authored-by: Sarah Rainsberger <[email protected]>
Changes
(Disable whitespace diff recommended)
createShikiHighlighter
API to:codeToHast
andcodeToHtml
. The hast version allows the rehype plugin to syntax highlight more efficiently. Before it'shast -> text -> (highlight) hast -> html -> hast
, now it'shast -> text -> (highlight) hast
.<Code/>
component to key by lesser values and improve sharing the cached highlighter.Testing
Existing tests should pass. Also edited stuff due to new API names.
Docs
There's a few changesets, but
.changeset/large-zebras-sniff.md
is the main one for the astro major, which will go in the migration guide.