Skip to content

Commit dae11b7

Browse files
committed
refactor: improve code readability in C++ syntax highlighting logic
1 parent 3016e69 commit dae11b7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

antora-ui/src/js/vendor/cpp-highlight.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@ const CppHighlight = (function () {
7676
i += 2
7777
let depth = 1
7878
while (i < n && depth > 0) {
79-
if (code.slice(i, i + 2) === '[[') { depth++; i += 2 } else if (code.slice(i, i + 2) === ']]') { depth--; i += 2 } else i++
79+
if (code.slice(i, i + 2) === '[[') {
80+
depth++
81+
i += 2
82+
} else if (code.slice(i, i + 2) === ']]') {
83+
depth--
84+
i += 2
85+
} else {
86+
i++
87+
}
8088
}
8189
result.push(span('attribute', code.slice(start, i)))
8290
continue

0 commit comments

Comments
 (0)