MCPcopy Create free account
hub / github.com/betta-tech/byo-coding-agent / detectLanguage

Function detectLanguage

internal/ui/highlight.go:40–52  ·  view source on GitHub ↗

detectLanguage picks a Chroma lexer name from a leading-character peek. Returns "" when no lexer applies — caller skips highlighting in that case.

(s string)

Source from the content-addressed store, hash-verified

38// detectLanguage picks a Chroma lexer name from a leading-character peek.
39// Returns "" when no lexer applies — caller skips highlighting in that case.
40func detectLanguage(s string) string {
41 t := strings.TrimSpace(s)
42 if len(t) == 0 {
43 return ""
44 }
45 if t[0] == '{' || t[0] == '[' {
46 return "json"
47 }
48 if strings.HasPrefix(t, "--- ") {
49 return "diff"
50 }
51 return ""
52}

Callers 1

HighlightPayloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected