Add syntax highlighting

This commit is contained in:
dwrz
2026-07-10 13:07:05 +00:00
parent e0eed6a935
commit fee291a58f
6 changed files with 4042 additions and 3 deletions

View File

@@ -805,3 +805,22 @@ export class Renderer {
);
}
}
// Configure marked to use highlight.js for syntax highlighting.
// marked v8+ removed the highlight option from setOptions; use the
// marked-highlight extension instead.
if (
typeof marked !== 'undefined' &&
typeof markedHighlight !== 'undefined' &&
typeof hljs !== 'undefined'
) {
marked.use(
markedHighlight.markedHighlight({
langPrefix: 'hljs language-',
highlight(code, lang) {
const language = hljs.getLanguage(lang) ? lang : 'plaintext';
return hljs.highlight(code, { language }).value;
},
}),
);
}