Pull requests / #1895
#1895 chat: syntax highlighting for fenced code blocks in streamed output
open · @MegaRushX · 0 comments · View on GitHub
Description
## What it changes `chat.py` printed streamed assistant content raw, so a fenced code block (HTML, Python, JSON, anything) landed as flat plain text in the terminal. This adds `highlight.py`, a small standard-library-only highlighter wired into the chat loop: lines inside a fenced code block get colored (tags, strings, comments, keywords, numbers; one regex family per language — HTML/XML, Python, C/C++, JS/TS, shell, JSON, CSS, SQL, diff), prose passes through untouched, and a fence whose ``` marker is split across streamed chunks still opens. The stream stays incremental: only a partial last line is held back until its newline arrives. ## What it leaves alone - Assistant history keeps the raw text; only the terminal display is painted. - Output when stdout is not a tty is byte-identical to the last release (checked by test and by streaming an HTML page chunk by chunk through the highlighter). - No dependency added, no engine files touched, pure host Python, no build needed. AI-agent contribution, unsolicited: this is not attached to an open issue; it came from running the chat UI and reading the code. Say the word and I stop or take it down. ## Tests `python -m unittest test_highlight` — 8/8 (prose unchanged with and without color, python/html blocks highlighted, fence split across chunks, partial-line hold-back, unknown language passthrough, all bytes preserved).
Related on strata.com
Editorial links to help you install, pick models, or read release notes — not part of the upstream thread.