mdsvex-shiki
A highlighter for mdsvex using Shiki with support for most common transformers out of the box.
It was created to provide a better, more feature-rich, and customizable code highlighting solution for SvelteKit projects, addressing the limitations of mdsvex's built-in Prism highlighter.
Key Features & Purpose:
- Replaces mdsvex's default Prism highlighter with Shiki.
- Supports a wide array of Shiki transformers by default, including syntax highlighting for meta strings, words, diffs, and error levels.
- Offers a customizable title bar for code blocks, which can display the code block's title and language label.
- Includes a functional copy button to copy code to the clipboard.
- Provides extensive theming and configuration options through Shiki's native
codeToHtmlsettings.
Target Audience: Primarily developers using mdsvex within Svelte or SvelteKit projects who require advanced and aesthetically pleasing code syntax highlighting.
Configuration Highlights:
The library is configured within svelte.config.js as part of the mdsvex preprocessor. Key options include:
displayTitle: Controls the visibility of the title bar.displayLang: Controls the visibility of the language label.disableCopyButton: Controls the copy button.shikiOptions: Directly passes options (likethemeandtransformers) to Shiki.
Required Setup for Advanced Features: To use the title bar and copy button functionality, you must:
- Import the library's CSS file (
import '@mistweaverco/mdsvex-shiki/styles.css';). - Apply the provided
copyActionSvelte action to a container element wrapping your markdown content.
shikishikijssveltesveltekitsyntax-highlighting
Featured Stories
No featured articles.