mirror of
https://github.com/TriliumNext/Trilium.git
synced 2025-12-10 21:07:05 -06:00
fix(client/syntax_highlighting): avoid crash if language not found
This commit is contained in:
parent
95987d474d
commit
f36535d061
@ -61,7 +61,11 @@ export async function applySingleBlockSyntaxHighlight($codeBlock: JQuery<HTMLEle
|
|||||||
highlightedText = highlightAuto(text);
|
highlightedText = highlightAuto(text);
|
||||||
} else if (normalizedMimeType) {
|
} else if (normalizedMimeType) {
|
||||||
await ensureMimeTypesForHighlighting(normalizedMimeType);
|
await ensureMimeTypesForHighlighting(normalizedMimeType);
|
||||||
|
try {
|
||||||
highlightedText = highlight(text, { language: normalizedMimeType });
|
highlightedText = highlight(text, { language: normalizedMimeType });
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("Unable to apply syntax highlight.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlightedText) {
|
if (highlightedText) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user