Skip to content

Commit

Permalink
count
Browse files Browse the repository at this point in the history
  • Loading branch information
emmerich committed Apr 13, 2024
1 parent a3bbb9c commit 8f8ba01
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/components/DocumentView/CodeBlock/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type InlineIndexed = { inline: any; start: number; end: number };
type PositionedToken = ThemedToken & { start: number; end: number };

const tokenMutex = asyncMutexFunction();
let running = 0;
let count = 0;

/**
* Highlight a code block while preserving inline elements.
Expand All @@ -54,17 +54,15 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
await loadHighlighterLanguage(highlighter, langName);

const lines = await tokenMutex.runBlocking(async () => {
console.log(`running... ${running}`)
running ++;
count++;
const lines = highlighter.codeToTokensBase(code, {
lang: langName,
tokenizeMaxLineLength: 120,
});
running--;
return lines;
})

console.log(`${running} block has ${block.nodes.length} lines, ${code.length} characters ${inlines.length} inlines`);
console.log(`${count} block has ${block.nodes.length} lines, ${code.length} characters ${inlines.length} inlines`);
let currentIndex = 0;

return lines.map((tokens, index) => {
Expand Down

0 comments on commit 8f8ba01

Please sign in to comment.