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

Upgrade shiki #237

Open
brookslybrand opened this issue Mar 25, 2024 · 4 comments
Open

Upgrade shiki #237

brookslybrand opened this issue Mar 25, 2024 · 4 comments
Labels
good first issue Good for newcomers

Comments

@brookslybrand
Copy link
Contributor

Shiki, our code syntax highlighter, has undergone a number of upgrades since the current version we have (0.14.7). This is a major version upgrade, so there are some breaking changes

Migration guide

In order to stay up to date with bug fixes and the latest and greatest we should invest in upgrading this package

@brookslybrand brookslybrand added the good first issue Good for newcomers label Mar 25, 2024
@tlawrie
Copy link

tlawrie commented May 23, 2024

@brookslybrand could we use https://rehype-pretty.pages.dev/? I have swapped out the custom shiki for this in a fork and it works.

I didn't try it with custom themes as with yours, however it does have a themes option which might work.

@brookslybrand
Copy link
Contributor Author

@brookslybrand could we use https://rehype-pretty.pages.dev/? I have swapped out the custom shiki for this in a fork and it works.

I didn't try it with custom themes as with yours, however it does have a themes option which might work.

I'm not totally against it, but since I didn't really build this part and try to not touch it too much since it's all working correctly, I'm a bit hesitant to change it. Do you think it'd just be more maintainable? I'm open to a PR

@tlawrie
Copy link

tlawrie commented May 24, 2024

@brookslybrand I have made some progress

This uses the latests shiki and replaces ~230 with ~10.

However, having trouble getting the line highlighting working and the numbered rows

Left is website. Right is local.

image

@tlawrie
Copy link

tlawrie commented May 27, 2024

@brookslybrand I have it, using a framework and cutting out the code.

Required changes to the MD meta strings

  • the highlighter syntax changes from the custom lines[4,12] to the standard syntax tsx {10,14}
  • the filename meta string changes from filename=app/components/button/styles.module.css to title="app/components/button/styles.module.css"

Other cosmetic differences:

  • the copy button is of a slightly different style and always present. I can make it 'hover' only but it doesn't show up on hover of the code block and instead you need to hover over the actual button. I have made it always present with an opacity.
  • if the code block has a title area, the copy button is still on the code section of the code block and not in the title section.
image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants