MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / createMarkdownTheme

Function createMarkdownTheme

apps/kimi-code/src/tui/theme/pi-tui-theme.ts:25–61  ·  view source on GitHub ↗
(options?: { transient?: boolean })

Source from the content-addressed store, hash-verified

23const HEADING_HASH_PREFIX = /^((?:\u001B\[[0-9;]*m)*)#{1,6}[ \t]+/;
24
25export function createMarkdownTheme(options?: { transient?: boolean }): MarkdownTheme {
26 const transient = options?.transient === true;
27 const stripHash = (text: string): string => text.replace(HEADING_HASH_PREFIX, '$1');
28
29 return {
30 heading: (text) => chalk.bold.hex(currentTheme.color('text'))(stripHash(text)),
31 link: (text) => chalk.hex(currentTheme.color('primary'))(text),
32 linkUrl: (text) => chalk.hex(currentTheme.color('textMuted'))(text),
33 code: (text) => chalk.hex(currentTheme.color('primary'))(text),
34 codeBlock: (text) => text,
35 codeBlockBorder: (text) => chalk.hex(currentTheme.color('textMuted'))(text),
36 quote: (text) => chalk.hex(currentTheme.color('textDim'))(text),
37 quoteBorder: (text) => chalk.hex(currentTheme.color('textDim'))(text),
38 hr: (text) => chalk.hex(currentTheme.color('border'))(text),
39 // Match the assistant-message bullet so list markers read like a reply
40 // prefix. Ordered lists arrive as "1. " / "2. " and are left
41 // untouched by the leading-dash anchor.
42 listBullet: (text) => chalk.hex(currentTheme.color('text'))(text.replace(/^-/, '•')),
43 bold: (text) => chalk.bold(text),
44 italic: (text) => chalk.italic(text),
45 strikethrough: (text) => chalk.strikethrough(text),
46 underline: (text) => chalk.underline(text),
47 highlightCode: (code: string, lang?: string) => {
48 if (transient) return code.split('\n');
49
50 const normalizedLang = lang?.trim().toLowerCase();
51 const language =
52 normalizedLang !== undefined && supportsLanguage(normalizedLang) ? normalizedLang : 'text';
53 try {
54 const highlighted = highlight(code, { language, ignoreIllegals: true });
55 return highlighted.split('\n');
56 } catch {
57 return code.split('\n');
58 }
59 },
60 };
61}
62
63export function createEditorTheme(): EditorTheme {
64 return {

Callers 6

plan-box.test.tsFile · 0.90
openMethod · 0.90
ToolCallComponentClass · 0.90
updateContentMethod · 0.90
invalidateMethod · 0.90

Calls 6

stripHashFunction · 0.85
colorMethod · 0.80
boldMethod · 0.80
italicMethod · 0.80
strikethroughMethod · 0.80
underlineMethod · 0.80

Tested by

no test coverage detected