fix(editor): 暗色 type 色值修正 + extractLang 小写化

- .dark .hljs-type/.hljs-title.class_ 由 #8839ef(紫) 改为 #f9e2af(黄),
  与 spec 表、官方 @catppuccin/highlightjs、读者侧 highlight.css 三处对齐
- extractLang 加 toLowerCase,与后端 parse_fence_info(languages.rs:85)对齐,
  避免大写语言名触发 lowlight Unknown language 抛错
This commit is contained in:
xfy 2026-07-06 16:13:08 +08:00
parent 4de48cd16c
commit 0adc6d8382
3 changed files with 9 additions and 5 deletions

View File

@ -14,6 +14,8 @@ describe('extractLang', () => {
[' python ', 'python', '前后空格(trim)'], [' python ', 'python', '前后空格(trim)'],
['', '', '空字符串'], ['', '', '空字符串'],
[' ', '', '纯空格'], [' ', '', '纯空格'],
['PYTHON', 'python', '大写小写化(与后端对齐)'],
['Python Runnable', 'python', '混合大小写'],
])('%s → %s (%s)', (input, expected) => { ])('%s → %s (%s)', (input, expected) => {
expect(extractLang(input)).toBe(expected); expect(extractLang(input)).toBe(expected);
}); });

View File

@ -3,13 +3,15 @@ import { common, createLowlight } from 'lowlight';
const base = createLowlight(common); const base = createLowlight(common);
/** /**
* fence info string token * fence info string token
* *
* parse_fence_infosrc/api/code_runner/languages.rs:80 * parse_fence_infosrc/api/code_runner/languages.rs:85
* info string `python runnable {"timeout_secs":10}` token * info string `python runnable {"timeout_secs":10}` token
* to_lowercaselowlight Unknown language
*/ */
export function extractLang(info: string): string { export function extractLang(info: string): string {
return info.trim().split(/\s+/)[0] || ''; const first = info.trim().split(/\s+/)[0];
return first ? first.toLowerCase() : '';
} }
/** /**

View File

@ -903,7 +903,7 @@
} }
.dark .tiptap-editor pre code .hljs-type, .dark .tiptap-editor pre code .hljs-type,
.dark .tiptap-editor pre code .hljs-title.class_ { .dark .tiptap-editor pre code .hljs-title.class_ {
color: #8839ef; color: #f9e2af;
} }
.dark .tiptap-editor pre code .hljs-built_in, .dark .tiptap-editor pre code .hljs-built_in,
.dark .tiptap-editor pre code .hljs-doctag { .dark .tiptap-editor pre code .hljs-doctag {