fix: Calling "getLanguage" manually causes highlighting to fail
This commit is contained in:
parent
04b598599a
commit
95b093b938
1 changed files with 1 additions and 2 deletions
|
|
@ -142,7 +142,6 @@ export class Diff2HtmlUI {
|
|||
// HACK: help Typescript know that `this.hljs` is defined since we already checked it
|
||||
if (this.hljs === null) return;
|
||||
const language = file.getAttribute('data-lang');
|
||||
const hljsLanguage = language ? this.hljs.getLanguage(language) : undefined;
|
||||
|
||||
// Collect all the code lines and execute the highlight on them
|
||||
const codeLines = file.querySelectorAll('.d2h-code-line-ctn');
|
||||
|
|
@ -157,7 +156,7 @@ export class Diff2HtmlUI {
|
|||
|
||||
const result: HighlightResult = closeTags(
|
||||
this.hljs.highlight(text, {
|
||||
language: hljsLanguage?.name || 'plaintext',
|
||||
language: language || 'plaintext',
|
||||
ignoreIllegals: true,
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue