logo
  • 現在做什麼
  • 關於我

Kalan

文章分類

  • 前端
  • 開發筆記
  • 雜談
  • 年度回顧

快速連結

  • 現在做什麼
  • 關於我
  • 聯絡我
  • 職涯思考🔗

關注我

在福岡生活的開發者,分享軟體開發與日本生活的點點滴滴。

© 2025 Kalan Made with ❤️. All rights reserved.

Change from prismjs to shiki

Written byKalanKalanNov 7, 2021
Home/Frontend
💡

If you have any questions or feedback, pleasefill out this form

Japanese原文

Table of Contents

    This post is translated by ChatGPT and originally written in Mandarin, so there may be some inaccuracies or mistakes.

    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 to cpp.

    Here’s what I came up with:

    const Component = () => <MyComponent />
    ← tmux Shortcut Key NotesSeveral use cases of useMemo →

    If you found this article helpful, please consider buying me a coffee ☕ It'll make my ordinary day shine ✨

    ☕Buy me a coffee