mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(coding-agent): disable cli-highlight auto-detection for languageless code blocks
cli-highlight's auto-detection misidentifies prose as AppleScript, LiveCodeServer, etc., coloring random English words (if, but, and, the, that, is) as keywords. This happens when code blocks have no language specified: fenced blocks without a language tag, indented code blocks, or unclosed fences during streaming. Skip auto-detection entirely and apply plain mdCodeBlock styling instead.
This commit is contained in:
parent
77db2e4c18
commit
f90647ea8e
1 changed files with 12 additions and 0 deletions
|
|
@ -978,6 +978,12 @@ function getCliHighlightTheme(t: Theme): CliHighlightTheme {
|
|||
export function highlightCode(code: string, lang?: string): string[] {
|
||||
// Validate language before highlighting to avoid stderr spam from cli-highlight
|
||||
const validLang = lang && supportsLanguage(lang) ? lang : undefined;
|
||||
// Skip highlighting when no valid language is specified. cli-highlight's
|
||||
// auto-detection is unreliable and can misidentify prose as AppleScript,
|
||||
// LiveCodeServer, etc., coloring random English words as keywords.
|
||||
if (!validLang) {
|
||||
return code.split("\n").map((line) => theme.fg("mdCodeBlock", line));
|
||||
}
|
||||
const opts = {
|
||||
language: validLang,
|
||||
ignoreIllegals: true,
|
||||
|
|
@ -1080,6 +1086,12 @@ export function getMarkdownTheme(): MarkdownTheme {
|
|||
highlightCode: (code: string, lang?: string): string[] => {
|
||||
// Validate language before highlighting to avoid stderr spam from cli-highlight
|
||||
const validLang = lang && supportsLanguage(lang) ? lang : undefined;
|
||||
// Skip highlighting when no valid language is specified. cli-highlight's
|
||||
// auto-detection is unreliable and can misidentify prose as AppleScript,
|
||||
// LiveCodeServer, etc., coloring random English words as keywords.
|
||||
if (!validLang) {
|
||||
return code.split("\n").map((line) => theme.fg("mdCodeBlock", line));
|
||||
}
|
||||
const opts = {
|
||||
language: validLang,
|
||||
ignoreIllegals: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue