Closed mateusfg7 closed 6 months ago
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:
Works when I use fs.readFileSync instead of await readFile()
fs.readFileSync
await readFile()
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
The result: