Skip to content

Commit c948523

Browse files
committed
fix: complete Chroma syntax highlighting for code blocks
Style all token types so JSON keys, punctuation, builtins, exceptions, decorators, diffs, etc. are properly colored instead of rendering as plain text.
1 parent 12238a6 commit c948523

1 file changed

Lines changed: 43 additions & 22 deletions

File tree

‎internal/styles/markdown.go‎

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -191,28 +191,49 @@ func markdownStyle(t Theme) ansi.StyleConfig {
191191
Margin: uintPtr(0),
192192
},
193193
Chroma: &ansi.Chroma{
194-
Text: ansi.StylePrimitive{
195-
Color: text,
196-
},
197-
Keyword: ansi.StylePrimitive{
198-
Color: accent,
199-
},
200-
Name: ansi.StylePrimitive{
201-
Color: text,
202-
},
203-
NameFunction: ansi.StylePrimitive{
204-
Color: accent,
205-
},
206-
LiteralString: ansi.StylePrimitive{
207-
Color: stringPtr(colorToHex(t.SuccessFg)),
208-
},
209-
LiteralNumber: ansi.StylePrimitive{
210-
Color: stringPtr(colorToHex(t.WarningFg)),
211-
},
212-
Comment: ansi.StylePrimitive{
213-
Color: muted,
214-
Italic: boolPtr(true),
215-
},
194+
// Base
195+
Text: ansi.StylePrimitive{Color: text},
196+
Error: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.ErrorFg))},
197+
198+
// Comments
199+
Comment: ansi.StylePrimitive{Color: muted, Italic: boolPtr(true)},
200+
CommentPreproc: ansi.StylePrimitive{Color: muted, Italic: boolPtr(true)},
201+
202+
// Keywords (if/else/for, true/false/null, import, int/string, class/struct)
203+
Keyword: ansi.StylePrimitive{Color: accent},
204+
KeywordReserved: ansi.StylePrimitive{Color: accent},
205+
KeywordNamespace: ansi.StylePrimitive{Color: accent},
206+
KeywordType: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.InfoFg))},
207+
208+
// Operators & punctuation ({}, :, =, +)
209+
Operator: ansi.StylePrimitive{Color: text},
210+
Punctuation: ansi.StylePrimitive{Color: muted},
211+
212+
// Names (variables, functions, classes, JSON keys, decorators)
213+
Name: ansi.StylePrimitive{Color: text},
214+
NameBuiltin: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.InfoFg))},
215+
NameTag: ansi.StylePrimitive{Color: accent},
216+
NameAttribute: ansi.StylePrimitive{Color: accent},
217+
NameClass: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.InfoFg)), Bold: boolPtr(true)},
218+
NameConstant: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.WarningFg))},
219+
NameDecorator: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.InfoFg))},
220+
NameException: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.ErrorFg))},
221+
NameFunction: ansi.StylePrimitive{Color: accent},
222+
NameOther: ansi.StylePrimitive{Color: text},
223+
224+
// Literals (strings, numbers, dates)
225+
Literal: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.SuccessFg))},
226+
LiteralNumber: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.WarningFg))},
227+
LiteralDate: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.WarningFg))},
228+
LiteralString: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.SuccessFg))},
229+
LiteralStringEscape: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.WarningFg))},
230+
231+
// Diff
232+
GenericDeleted: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.ErrorFg))},
233+
GenericEmph: ansi.StylePrimitive{Italic: boolPtr(true)},
234+
GenericInserted: ansi.StylePrimitive{Color: stringPtr(colorToHex(t.SuccessFg))},
235+
GenericStrong: ansi.StylePrimitive{Bold: boolPtr(true)},
236+
GenericSubheading: ansi.StylePrimitive{Color: muted},
216237
},
217238
},
218239
Table: ansi.StyleTable{

0 commit comments

Comments
 (0)