Skip to content

Commit 9bcf38b

Browse files
committed
fix: 修复 language='typescript' 未被 mapLanguage 识别导致代码块无高亮
1 parent cfeed16 commit 9bcf38b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/utils/prism.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function normalizeLanguage(
9494

9595
function mapLanguage(raw: string): CodeLanguage | null {
9696
if (!raw) return null;
97-
if (raw === 'ts') return 'typescript';
97+
if (raw === 'ts' || raw === 'typescript') return 'typescript';
9898
if (raw === 'tsx') return 'tsx';
9999
if (raw === 'js' || raw === 'javascript') return 'javascript';
100100
if (raw === 'jsx') return 'jsx';
@@ -194,7 +194,7 @@ export function inferLanguageFromCode(code: string): CodeLanguage | null {
194194
return 'typescript';
195195
}
196196

197-
if (c.includes('function ') || c.includes('const ') || c.includes('let ')) {
197+
if (c.includes('function ') || c.includes('const ') || c.includes('let ') || c.includes('class ')) {
198198
return 'typescript';
199199
}
200200

0 commit comments

Comments
 (0)