File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { describe , expect , it } from "vite-plus/test" ;
2+
3+ import { resolveHighlightLanguage } from "./highlightLanguage" ;
4+
5+ describe ( "resolveHighlightLanguage" , ( ) => {
6+ it . each ( [
7+ [ "src/init.luau" , "lua" ] ,
8+ [ "styles/page.xsl" , "xml" ] ,
9+ [ "styles/page.xslt" , "xml" ] ,
10+ ] ) ( "%s highlights as %s" , ( path , language ) => {
11+ expect ( resolveHighlightLanguage ( { path } ) ) . toBe ( language ) ;
12+ } ) ;
13+ } ) ;
Original file line number Diff line number Diff line change 11import "@t3tools/client-runtime/assembly-highlighting" ;
2- import { getFiletypeFromFileName } from "@pierre/diffs/utils/getFiletypeFromFileName" ;
2+ import {
3+ getFiletypeFromFileName ,
4+ setCustomExtension ,
5+ } from "@pierre/diffs/utils/getFiletypeFromFileName" ;
36
47import { HIGHLIGHTS_LANGUAGE_IDS } from "./highlights.generated" ;
58
9+ // Highlights has no lexer for these dialects, so they use their base language's.
10+ setCustomExtension ( "luau" , "lua" ) ;
11+ setCustomExtension ( "xsl" , "xml" ) ;
12+ setCustomExtension ( "xslt" , "xml" ) ;
13+
614/** The native lexer ID for a @pierre/highlights language name, or 0 (plain text). */
715export function highlightLanguageId ( language : string ) : number {
816 return Object . hasOwn ( HIGHLIGHTS_LANGUAGE_IDS , language ) ? HIGHLIGHTS_LANGUAGE_IDS [ language ] ! : 0 ;
Original file line number Diff line number Diff line change 11import { getFiletypeFromFileName } from "@pierre/diffs" ;
2- import { expect , it } from "vite-plus/test" ;
2+ import { describe , expect , it } from "vite-plus/test" ;
33
44import { getSyntaxHighlighterPromise } from "./syntaxHighlighting" ;
55import { DIFF_THEME_NAMES } from "./diffRendering" ;
66
7+ describe ( "dialect file types" , ( ) => {
8+ it . each ( [
9+ [ "src/init.luau" , "lua" ] ,
10+ [ "styles/page.xsl" , "xml" ] ,
11+ [ "styles/page.xslt" , "xml" ] ,
12+ ] ) ( "%s highlights as %s" , ( path , language ) => {
13+ expect ( getFiletypeFromFileName ( path ) ) . toBe ( language ) ;
14+ } ) ;
15+ } ) ;
16+
717it . each ( [
818 "asm" ,
919 "assembly" ,
Original file line number Diff line number Diff line change 11import "@t3tools/client-runtime/assembly-highlighting" ;
22import {
33 getSharedHighlighter ,
4+ setCustomExtension ,
45 type DiffsHighlighter ,
56 type HighlighterTypes ,
67 type SupportedLanguages ,
78} from "@pierre/diffs" ;
89
910import { DIFF_THEME_NAMES } from "./diffRendering" ;
1011
12+ // Highlights has no lexer for these dialects, so they use their base language's.
13+ setCustomExtension ( "luau" , "lua" ) ;
14+ setCustomExtension ( "xsl" , "xml" ) ;
15+ setCustomExtension ( "xslt" , "xml" ) ;
16+
1117/**
1218 * Highlights' hand-written WASM lexers tokenize large files 10-40x faster than
1319 * Shiki and never backtrack like Shiki's JS regex engine. Only one highlighter
You can’t perform that action at this time.
0 commit comments