check for language in highlighting

This commit is contained in:
Philipp Kühn 2021-04-02 22:21:17 +02:00
parent c8f384b9fc
commit faa0ef8bfa

View File

@ -48,7 +48,13 @@ function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) {
blocks.forEach(block => {
let startPos = block.pos + 1
const nodes = low.highlightAuto(block.node.textContent).value
const { language } = block.node.attrs
// TODO: add missing type for `listLanguages`
// @ts-ignore
const languages = low.listLanguages() as string[]
const nodes = language && languages.includes(language)
? low.highlight(language, block.node.textContent).value
: low.highlightAuto(block.node.textContent).value
parseNodes(nodes)
.flat()