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

Fix Code.astro shiki css class replace logic #5829

Merged
merged 2 commits into from
Jan 11, 2023
Merged

Fix Code.astro shiki css class replace logic #5829

merged 2 commits into from
Jan 11, 2023

Conversation

giuseppelt
Copy link
Contributor

@giuseppelt giuseppelt commented Jan 11, 2023

Changes

The replace uses a regex witch matches anything extra and adds it back to the css class.

Closes #5828

Testing

As mentioned in the linked issue #5828, the actual pinned shiki version v0.11 does work. The v0.12 causes the bug, as a new feature shikijs/shiki#376 adds an extra css class, making the actual logic to fail.

There's a test already in place

it('<Code theme="...">', async () => {
let html = await fixture.readFile('/custom-theme/index.html');
const $ = cheerio.load(html);
expect($('pre')).to.have.lengthOf(1);
expect($('pre').attr('class')).to.equal('astro-code');
and it will fail when shiki gets updated to v0.12. This PR resolves the issue.

Docs

The replace uses a regex witch matches anything extra, and adds it back to the css class.

Closes #5828
@changeset-bot
Copy link

changeset-bot bot commented Jan 11, 2023

🦋 Changeset detected

Latest commit: 69b872c

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 11, 2023
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code.astro component no longer set .astro-code css class
2 participants