8356
Wx
www-xonecas-io / files
www-xonecas-io / tickets / 1024-markdown-code-snippets-are-not-syntax.md
2.7 KB
1--- 2id: 1024 3title: markdown code snippets are not syntax highlighted 4type: feature 5status: done 6priority: p2 7created: 2026-11-08T04:12:36Z 8updated: 2026-11-08T20:16:26Z 9source: devnote 10area: site 11moves: 2026-11-08T04:37:43Z inbox doing drag; 2026-11-08T04:40:31Z doing review agent; 2026-11-08T20:16:26Z review done drag 12--- 13 14## Context 15 16Filed from `http://192.168.122.10:8080/projects/cel-tui/`, on `pre`. 17 18> import { cel, VStack, Text, TextInput, ProcessTerminal } from "@cel-tui/core"; 19> let input = ""; 20> cel.init(new ProcessTerminal()); 21> cel.viewport(() => 22> VStack( 23> { 24> height: "100%", 25> onKeyPress: (key) => { 26> if (key === "ctrl+q") { 27> cel.stop(); 28> process.exit(); 29> } 30> }, 31> }, 32> [ 33> Text("Hello, cel-tui!", { bold: true, fgColor: "color06" }), 34> Text("─", { repeat: "fill", fgColor: "color08" }), 35> TextInput({ 36> flex: 1, 37> value: input, 38> onChange: (v) => { 39> input = v; 40> cel.render(); 41> }, 42> }), 43> … 44 45## Notes 46 47- 2026-11-08 04:23Z (agent): Triage: type feature (it was bug: READMEs were never highlighted), priority p2, area site. No typos to fix. 48 49 READMEs render with goldmark (internal/site/readme.go) with no code highlighting, so fenced blocks come out as plain <pre><code class="language-ts">. The file browser already highlights with chroma (browse.go highlight(), palette in site.css), so the same palette can be reused for README code blocks by fence language. Related: 1008. 50 51- 2026-11-08 04:40Z (agent): Done. README fenced code blocks are now coloured by the fence's language, in the same palette as the file pages (keywords, strings, numbers, comments and so on). 52 53 - internal/site/readme.go: a small goldmark renderer for fenced blocks picks the chroma lexer from the fence language and writes <pre><code class="code language-x">. No language, or one chroma does not know (text, txt, none), stays plain. 54 - browse.go: the token code is split out of highlight() into tokenise() and writeTokens(), so file pages and READMEs share it. File pages are unchanged. 55 - readme_test.go: a go block gets <b class="k">func</b>; an unknown language stays escaped plain text. 56 57 CHECKED: go vet, go test pass. Rebuilt: 136 fenced blocks across all READMEs, 70 now carry colour. All ts, typescript, lua, json, javascript and html blocks are coloured. bash and sh only where they have something to colour (17 of 47, 7 of 12): one-line commands like 'npm i -g mini-coder' are plain words in bash's lexer. Screenshot of cel-tui's Quick Example in light theme looks like the file pages. 58 59 NOT CHECKED: dark theme (the code block is dark in both, same palette as file pages).