Increase max line length for code highlighting (#3415)

Co-authored-by: Nicolas Dorseuil <nicolas@gitbook.io>
This commit is contained in:
conico974
2025-07-03 13:05:42 +02:00
committed by GitHub
parent c16890a3a6
commit 78c10340e7
@@ -77,10 +77,17 @@ export async function highlight(
themes: [theme],
});
let tokenizeMaxLineLength = 400;
// In some cases, people will use unindented code blocks with a single line.
// In this case, we can safely increase the max line length to avoid not highlighting the code.
if (block.nodes.length === 1) {
tokenizeMaxLineLength = 5000;
}
const lines = highlighter.codeToTokensBase(code, {
lang: langName,
theme,
tokenizeMaxLineLength: 400,
tokenizeMaxLineLength,
});
let currentIndex = 0;