Skip to content

Commit

Permalink
docs: guide for adding custom grammars for syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
ashour committed Apr 28, 2023
1 parent 82ccc1f commit 7da9b28
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/content/4.api/3.configuration.md
Expand Up @@ -317,6 +317,36 @@ export default defineNuxtConfig({
})
```

If you wish to add highlighting for an unsupported language, you can do so by loading the grammar file for the language.

```ts
import { readFileSync } from 'fs'

export default defineNuxtConfig({
content: {
highlight: {
preload: [
{
id: 'gdscript',
scopeName: 'source.gdscript',
aliases: ['gdscript', 'gd'], // Use to mark code blocks in Markdown
grammar: JSON.parse(
readFileSync(
// Place the language grammar file somewhere in your project
'./shiki/languages/gdscript.tmLanguage.json'
).toString()
),
},
],
},
},
})

```

Read more about adding languages in the [Shiki documentation](https://github.com/shikijs/shiki/blob/main/docs/languages.md#adding-grammar).


## `yaml`

- Type: `false | Object`{lang=ts}
Expand Down

0 comments on commit 7da9b28

Please sign in to comment.