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

Add Shiki as an alternative to Prism #2497

Merged
merged 14 commits into from
Jan 31, 2022
Merged

Add Shiki as an alternative to Prism #2497

merged 14 commits into from
Jan 31, 2022

Conversation

JuanM04
Copy link
Contributor

@JuanM04 JuanM04 commented Jan 29, 2022

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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pkg: example Related to an example package (scope) feat: markdown Related to Markdown (scope) labels Jan 29, 2022
@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2022

🦋 Changeset detected

Latest commit: 57eb46a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@astrojs/markdown-remark Patch
astro Patch

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

@netlify
Copy link

netlify bot commented Jan 29, 2022

✔️ 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

@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2022

⚠️ No Changeset found

Latest commit: 7cf77e3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@JuanM04 JuanM04 changed the title Added Shiki to markdown-remark Add Shiki as an alternative to Prism Jan 29, 2022
@github-actions github-actions bot added the test label Jan 29, 2022
Copy link
Contributor

@jonathantneal jonathantneal left a 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 });
Copy link
Contributor

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@natemoo-re natemoo-re left a 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!

@natemoo-re natemoo-re merged commit 6fe1b02 into withastro:main Jan 31, 2022
@github-actions github-actions bot mentioned this pull request Jan 31, 2022
@JuanM04 JuanM04 deleted the shiki-md branch January 31, 2022 22:25
@github-actions github-actions bot mentioned this pull request Feb 18, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* [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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: markdown Related to Markdown (scope) pkg: astro Related to the core `astro` package (scope) pkg: example Related to an example package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants