@@ -9,6 +9,7 @@ export interface Diff2HtmlUIConfig extends Diff2HtmlConfig {
99 highlight ?: boolean ;
1010 fileListToggle ?: boolean ;
1111 fileListStartVisible ?: boolean ;
12+ highlightLanguages ?: Map < string , string > ;
1213 /**
1314 * @deprecated since version 3.1.0
1415 * Smart selection is now enabled by default with vanilla CSS
@@ -23,6 +24,7 @@ export const defaultDiff2HtmlUIConfig = {
2324 highlight : true ,
2425 fileListToggle : true ,
2526 fileListStartVisible : false ,
27+ highlightLanguages : new Map < string , string > ( ) ,
2628 /**
2729 * @deprecated since version 3.1.0
2830 * Smart selection is now enabled by default with vanilla CSS
@@ -141,8 +143,16 @@ export class Diff2HtmlUI {
141143 files . forEach ( file => {
142144 // HACK: help Typescript know that `this.hljs` is defined since we already checked it
143145 if ( this . hljs === null ) return ;
146+
144147 const language = file . getAttribute ( 'data-lang' ) ;
145- const hljsLanguage = language ? getLanguage ( language ) : 'plaintext' ;
148+
149+ const hljsLanguage =
150+ language && this . config . highlightLanguages . has ( language )
151+ ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
152+ this . config . highlightLanguages . get ( language ) !
153+ : language
154+ ? getLanguage ( language )
155+ : 'plaintext' ;
146156
147157 // Collect all the code lines and execute the highlight on them
148158 const codeLines = file . querySelectorAll ( '.d2h-code-line-ctn' ) ;
0 commit comments