Handle case where the language is known but not loaded into HLJS
This commit is contained in:
parent
41a901694d
commit
6095b3a4e9
1 changed files with 4 additions and 1 deletions
|
|
@ -151,13 +151,16 @@ export class Diff2HtmlUI {
|
|||
this.config.highlightLanguages = new Map(Object.entries(this.config.highlightLanguages));
|
||||
}
|
||||
|
||||
const hljsLanguage =
|
||||
let hljsLanguage =
|
||||
language && this.config.highlightLanguages.has(language)
|
||||
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this.config.highlightLanguages.get(language)!
|
||||
: language
|
||||
? getLanguage(language)
|
||||
: 'plaintext';
|
||||
if (language !== null && hljs.getLanguage(language) === undefined) {
|
||||
hljsLanguage = 'plaintext';
|
||||
}
|
||||
|
||||
// Collect all the code lines and execute the highlight on them
|
||||
const codeLines = file.querySelectorAll('.d2h-code-line-ctn');
|
||||
|
|
|
|||
Loading…
Reference in a new issue