Syntax Highlighting
Explainer uses Shiki for syntax highlighting with dual theme support — automatically switching between light and dark themes.
Themes
Two themes are configured out of the box:
| Mode | Theme |
|---|---|
| Light | github-light |
| Dark | github-dark |
The active theme follows the user’s system preference or manual toggle.
Usage
Use standard Markdown fenced code blocks with a language identifier:
```ts
function greet(name: string): string {
return `Hello, ${name}!`
}
```
Renders as:
function greet(name: string): string {
return `Hello, ${name}!`
}
Supported languages
Shiki supports 200+ languages. Common examples:
echo "Shell scripts"
def hello():
print("Python")
fn main() {
println!("Rust");
}
{
"key": "JSON"
}
Active transformers
Explainer enables several Shiki transformers for enhanced code block features:
| Transformer | Purpose | Docs |
|---|---|---|
transformerNotationDiff | [!code ++] / [!code --] diff markers | Diffs & Focus |
transformerNotationHighlight | [!code highlight] line emphasis | Line Highlighting |
transformerNotationWordHighlight | [!code word:name] word emphasis | Line Highlighting |
transformerNotationFocus | [!code focus] focus mode | Diffs & Focus |
transformerNotationErrorLevel | [!code error] error markers | Diffs & Focus |
transformerMetaHighlight | {1,3-4} line range highlighting | Line Highlighting |
transformerMetaLabel | [label] code block labels | Labels & Icons |