File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { expect , test } from "bun:test" ;
2- import { SHIKI_FILE_LANGUAGES } from "./highlighter" ;
2+ import { createJavaScriptRegexEngine } from "shiki/engine/javascript" ;
3+ import {
4+ chatShikiLanguageId ,
5+ createChatHighlighter ,
6+ SHIKI_FILE_LANGUAGES ,
7+ shikiLanguageId ,
8+ } from "./highlighter" ;
39
410test ( "the Monaco Shiki language registration list has no duplicate ids" , ( ) => {
511 const ids = SHIKI_FILE_LANGUAGES . map ( ( language ) => language . id ) ;
612 expect ( new Set ( ids ) . size ) . toBe ( ids . length ) ;
713} ) ;
814
15+ test ( "Scala is recognized for chat fences and Scala files" , ( ) => {
16+ const scala = SHIKI_FILE_LANGUAGES . find ( ( language ) => language . id === "scala" ) ;
17+ expect ( scala ?. extensions ) . toContain ( ".scala" ) ;
18+ expect ( scala ?. chat ) . toBe ( true ) ;
19+ expect ( shikiLanguageId ( "Scala" ) ) . toBe ( "scala" ) ;
20+ expect ( chatShikiLanguageId ( "scala" ) ) . toBe ( "scala" ) ;
21+ } ) ;
22+
23+ test ( "a Scala chat fence renders with Shiki tokens" , async ( ) => {
24+ const highlight = createChatHighlighter ( createJavaScriptRegexEngine ) ;
25+ const html = await highlight ( 'object Greeting { val message: String = "hello" }' , "scala" ) ;
26+ expect ( html ) . not . toBeNull ( ) ;
27+ expect ( html ) . toContain ( "<span" ) ;
28+ } ) ;
29+
930test ( "every Monaco language id is supplied by its Shiki grammar" , async ( ) => {
1031 const modules = await Promise . all ( SHIKI_FILE_LANGUAGES . map ( ( language ) => language . load ( ) ) ) ;
1132 for ( const [ index , language ] of SHIKI_FILE_LANGUAGES . entries ( ) ) {
Original file line number Diff line number Diff line change @@ -139,6 +139,13 @@ export const SHIKI_FILE_LANGUAGES: readonly ShikiFileLanguage[] = [
139139 aliases : [ "Kotlin" , "kt" , "kts" ] ,
140140 load : ( ) => import ( "@shikijs/langs/kotlin" ) ,
141141 } ,
142+ {
143+ id : "scala" ,
144+ extensions : [ ".scala" ] ,
145+ aliases : [ "Scala" ] ,
146+ chat : true ,
147+ load : ( ) => import ( "@shikijs/langs/scala" ) ,
148+ } ,
142149 {
143150 id : "swift" ,
144151 extensions : [ ".swift" ] ,
You can’t perform that action at this time.
0 commit comments