From b7b0490f40c8b90ea260b9682a9d987a44bf2ad7 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Sat, 13 Apr 2024 17:10:09 +0100 Subject: [PATCH] run blocking --- .../DocumentView/CodeBlock/highlight.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/DocumentView/CodeBlock/highlight.ts b/src/components/DocumentView/CodeBlock/highlight.ts index 8cccf145b..ed272ff7b 100644 --- a/src/components/DocumentView/CodeBlock/highlight.ts +++ b/src/components/DocumentView/CodeBlock/highlight.ts @@ -46,10 +46,13 @@ export async function highlight(block: DocumentBlockCode): Promise { + lineCount += block.nodes.length; + blockCount++; + return lineCount > LINE_LIMIT; + }) - if (lineCount > LINE_LIMIT) { + if (overLimit) { return plainHighlighting(block); } @@ -60,14 +63,12 @@ export async function highlight(block: DocumentBlockCode): Promise { - const highlighter = await loadHighlighter(); - await loadHighlighterLanguage(highlighter, langName); + const highlighter = await loadHighlighter(); + await loadHighlighterLanguage(highlighter, langName); - return highlighter.codeToTokensBase(code, { - lang: langName, - tokenizeMaxLineLength: 120, - }); + const lines = highlighter.codeToTokensBase(code, { + lang: langName, + tokenizeMaxLineLength: 120, }); console.log(