Add custom languages
mateusfg7 opened this issue · comments
Mateus Felipe Gonçalves commented
How can I add syntax highlight for a new custom language?
I follow this guide: https://shiki.style/guide/load-lang. And this guide: https://rehype-pretty-code.netlify.app/#custom-highlighter
But any of that seems to work.
My config
const options: Partial<Options> = {
theme: {
dark: 'github-dark',
light: 'github-light'
},
onVisitLine(node) {
// Prevent lines from collapsing in `display: grid` mode, and
// allow empty lines to be copy/pasted
if (node.children.length === 0) {
node.children = [{ type: 'text', value: ' ' }]
}
},
getHighlighter: options =>
getHighlighter({
...options,
langs: [
async () =>
JSON.parse(
await readFile('./content/plugin/visualg.tmLanguage.json', 'utf-8')
)
]
})
}
The result:
Mateus Felipe Gonçalves commented
Works when I use fs.readFileSync
instead of await readFile()