Skip to main content
Your posts might include code blocks that you want to style with syntax highlighting. This recipe shows how to use Shiki to transform your Marble content with beautiful code highlighting.
There are many syntax highlighting libraries available, such as Prism.js, highlight.js, and Shiki. This recipe uses Shiki.

Install Dependencies

Create a Highlighter

Create a utility function that transforms HTML content with syntax highlighting:
lib/highlight.ts

Use with the SDK

Apply the highlighter when fetching posts:

Configuration

Shiki supports many themes and languages. Update the createHighlighter options to match your needs:
For dual themes (light/dark mode), use:
For more configuration options, themes, and languages, see the Shiki documentation.