· 1 min read
Change from prismjs to shiki
# Frontend This article was auto-translated from Chinese. Some nuances may be lost in translation.
shiki is a package that provides syntax highlighting for code. It’s relatively newer compared to other packages like highlightjs and prismjs, and not as widely known. shiki uses TextMate grammar as its tokenizer definition, which means you can directly utilize grammars from other sources without needing to write custom language definitions. This standardization also makes it easier to expand in the future.
Additionally, it offers a rich variety of supported languages and is simpler to configure. With many built-in themes available, I easily replaced my original prismjs setup. Installing gatsby-remark-shiki and applying the configuration was straightforward—what a win!
I encountered a few minor issues:
- I originally used react’s highlight, so I had to change everything to jsx or tsx.
- If you’re using
c++, you need to switch it tocpp.
Here’s what I came up with:
const Component = () => <MyComponent /> Related Posts
- Make Your Hyperlink Underlines Look Better: text-underline-offsetBy default, underlines sit very close to the text, and some designers dislike this style. Personally, I don’t think it looks very good either.
- Why Web Design Shouldn’t Chase Pixel PerfectOnly pay attention to Pixel Perfect when it really matters; otherwise, it often leads to a lose-lose situation.
- Let’s Write Colors with CSS HSL! (And a Better Way)In web development, the traditional HEX and RGB color notations are widely used, but they are not very readable or intuitive, and their capabilities are limited in wider color spaces such as P3. HSL (Hue, Saturation, Lightness) provides a more intuitive way to define colors, making it easier for developers to understand and adjust them. By describing colors through the three dimensions of hue, saturation, and lightness, HSL makes color adjustment more human-friendly. In design systems in particular, HSL can better represent lightness variations in a color palette.
- The reasons to avoid setting line-height to 1 and using ellipsis whenever possibleThis article discusses why it's not advisable to set the line-height to 1 in web design, as well as the linguistic issues encountered when using ellipsis.