Skip to content

Commit 6069fbc

Browse files
committed
counts
1 parent 26d5afa commit 6069fbc

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/components/DocumentView/CodeBlock/highlight.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ type InlineIndexed = { inline: any; start: number; end: number };
2929

3030
type PositionedToken = ThemedToken & { start: number; end: number };
3131

32-
let counts = {
33-
blocks: 0,
34-
lines: 0,
35-
characters: 0,
36-
}
32+
let blockCount = 0;
33+
let lineCount = 0;
34+
let charCount = 0;
3735

3836
/**
3937
* Highlight a code block while preserving inline elements.
@@ -53,9 +51,9 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
5351
return a.start - b.start;
5452
});
5553

56-
counts.blocks += 1;
57-
counts.lines += block.nodes.length;
58-
counts.characters += code.length;
54+
blockCount += 1;
55+
lineCount += block.nodes.length;
56+
charCount += code.length;
5957

6058
const highlighter = await loadHighlighter();
6159
await loadHighlighterLanguage(highlighter, langName);
@@ -66,7 +64,7 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
6664
tokenizeMaxLineLength: 120,
6765
});
6866

69-
console.log(`${JSON.stringify(counts)} block has ${block.nodes.length} lines, ${code.length} characters ${inlines.length} inlines`);
67+
console.log(`${JSON.stringify({ blockCount, lineCount, charCount })} block has ${block.nodes.length} lines, ${code.length} characters ${inlines.length} inlines`);
7068
let currentIndex = 0;
7169

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

0 commit comments

Comments
 (0)