File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -151,14 +151,19 @@ export class Diff2HtmlUI {
151151 this . config . highlightLanguages = new Map ( Object . entries ( this . config . highlightLanguages ) ) ;
152152 }
153153
154- const hljsLanguage =
154+ let hljsLanguage =
155155 language && this . config . highlightLanguages . has ( language )
156156 ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
157157 this . config . highlightLanguages . get ( language ) !
158158 : language
159159 ? getLanguage ( language )
160160 : 'plaintext' ;
161161
162+ // Fallback to plaintext in case language is not loaded
163+ if ( hljs . getLanguage ( hljsLanguage ) === undefined ) {
164+ hljsLanguage = 'plaintext' ;
165+ }
166+
162167 // Collect all the code lines and execute the highlight on them
163168 const codeLines = file . querySelectorAll ( '.d2h-code-line-ctn' ) ;
164169 codeLines . forEach ( line => {
You can’t perform that action at this time.
0 commit comments