@@ -132,6 +132,34 @@ describe('should', () => {
132132 const code = shiki . codeToHtml ( 'const a: Foo = 1' , { lang : 'js' , theme : 'nord' } )
133133 expect ( code ) . toMatchInlineSnapshot ( `"<pre class="shiki nord" style="background-color:#2e3440ff;color:#d8dee9ff" tabindex="0"><code><span class="line"><span style="color:#81A1C1">const</span><span style="color:#D8DEE9"> a</span><span style="color:#81A1C1">:</span><span style="color:#8FBCBB"> Foo</span><span style="color:#81A1C1"> =</span><span style="color:#B48EAD"> 1</span></span></code></pre>"` )
134134 } )
135+
136+ it ( 'works with alias and special langs' , async ( ) => {
137+ using shiki = await createHighlighterCore ( {
138+ langAlias : {
139+ lang1 : 'text' ,
140+ lang2 : 'ansi' ,
141+ lang3 : 'lang4' ,
142+ lang4 : 'lang5' ,
143+ lang5 : 'ansi' ,
144+ } ,
145+ engine : createJavaScriptRegexEngine ( ) ,
146+ } )
147+
148+ await shiki . loadTheme ( nord )
149+
150+ const original1 = shiki . codeToHtml ( 'console.log("Hi")' , { lang : 'text' , theme : 'nord' } )
151+ const code1 = shiki . codeToHtml ( 'console.log("Hi")' , { lang : 'lang1' , theme : 'nord' } )
152+ expect ( code1 ) . toBe ( original1 )
153+
154+ const ansiCode = '[0;32mcolored foreground[0m[0;42mcolored background[0m[0;1mbold text[0m[0;2mdimmed text[0m[0;4munderlined text[0m[0;7mreversed text[0m[0;9mstrikethrough text[0m[0;4;9munderlined + strikethrough text[0m'
155+ const original2 = shiki . codeToHtml ( ansiCode , { lang : 'ansi' , theme : 'nord' } )
156+ const code2 = shiki . codeToHtml ( ansiCode , { lang : 'lang2' , theme : 'nord' } )
157+ expect ( code2 ) . toBe ( original2 )
158+
159+ // nested alias
160+ const code3 = shiki . codeToHtml ( ansiCode , { lang : 'lang3' , theme : 'nord' } )
161+ expect ( code3 ) . toBe ( original2 )
162+ } )
135163} )
136164
137165describe ( 'errors' , ( ) => {
0 commit comments