-
-
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
Add Shiki as an alternative to Prism #2497
Conversation
🦋 Changeset detectedLatest commit: 57eb46a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
✔️ Deploy Preview for astro-docs-2 ready! 🔨 Explore the source changes: eabd9cf 🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-docs-2/deploys/61f584f96e1f8a0008c27cd3 😎 Browse the preview: https://deploy-preview-2497--astro-docs-2.netlify.app |
|
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.
I would like a second look from a member who worked on the markdown component, but I like this.
Particularly packages/astro/components/Code.astro
@@ -43,7 +43,7 @@ function repairShikiTheme(html: string): string { | |||
} | |||
|
|||
const highlighter = await shiki.getHighlighter({ theme }); | |||
const _html = highlighter.codeToHtml(code, lang); | |||
const _html = highlighter.codeToHtml(code, { lang }); |
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.
Curious why this changed. Was this breaking? Or is this an optional way to pass the lang?
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.
Looks like they are both valid. I am fine with this change given that.
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.
It's not breaking, it's just deprecated: https://github.com/shikijs/shiki/blob/e40647c00a036c14ae5e28dfde007f59a6485c37/packages/shiki/src/types.ts#L36
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.
Looks great! Thank you so much for the contribution!
* [ci] yarn format * Added shiki to markdown-remark * Upgraded astro shiki * Added minimal example * Changed defaults to match <Code /> * Replace `shiki` with `astro` classes * Added documentation * Updated Astro code to use new `codeToHtml` * Added changesets * Added basic test * Updated tests a bit Co-authored-by: JuanM04 <JuanM04@users.noreply.github.com>
Changes
Adds Shiki to
@astrojs/markdown-remark
, in order to progress with RFC 3: Replace Prism with Shiki.Testing
yarn test:match "Shiki"
Docs
Here is documentation about the changes: https://deploy-preview-2497--astro-docs-2.netlify.app/en/guides/markdown-content/#syntax-highlighting