From 98036b229250d57614dcee2e4c1b9a389709b90d Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 13 Mar 2026 10:44:09 +0000 Subject: [PATCH] Add syntax highlighting to spreads page code blocks Use (highlight "..." "lisp") page helper instead of raw strings for ~docs/code :code values. Co-Authored-By: Claude Opus 4.6 --- sx/sx/spreads.sx | 63 ++++++------------------------------------------ 1 file changed, 7 insertions(+), 56 deletions(-) diff --git a/sx/sx/spreads.sx b/sx/sx/spreads.sx index 33488f1..d0a08fa 100644 --- a/sx/sx/spreads.sx +++ b/sx/sx/spreads.sx @@ -22,12 +22,9 @@ (p "A spread is a value type. " (code "make-spread") " creates one from a dict of " "attributes. When the renderer encounters a spread as a child of an element, " "it merges the attrs onto the parent element instead of appending a DOM node.") - (~docs/code :code "(defcomp ~highlight (&key colour) - (make-spread {\"class\" (str \"highlight-\" colour) - \"data-highlight\" colour}))") + (~docs/code :code (highlight "(defcomp ~highlight (&key colour)\n (make-spread {\"class\" (str \"highlight-\" colour)\n \"data-highlight\" colour}))" "lisp")) (p "Use it as a child of any element:") - (~docs/code :code "(div (~highlight :colour \"yellow\") - \"This div gets class=highlight-yellow\")") + (~docs/code :code (highlight "(div (~highlight :colour \"yellow\")\n \"This div gets class=highlight-yellow\")" "lisp")) (p (code "class") " values are appended (space-joined). " (code "style") " values are appended (semicolon-joined). " "All other attributes overwrite.")) @@ -35,13 +32,7 @@ (~docs/subsection :title "2. collect! / collected / clear-collected!" (p "Render-time accumulators. Values are collected into named buckets " "during rendering and retrieved at flush points. Deduplication is automatic.") - (~docs/code :code ";; Deep inside a component tree: -(collect! \"cssx\" \".sx-bg-red-500{background-color:hsl(0,72%,53%)}\") - -;; At the flush point (once, in the layout): -(let ((rules (collected \"cssx\"))) - (clear-collected! \"cssx\") - (raw! (str \"\")))") + (~docs/code :code (highlight ";; Deep inside a component tree:\n(collect! \"cssx\" \".sx-bg-red-500{background-color:hsl(0,72%,53%)}\")\n\n;; At the flush point (once, in the layout):\n(let ((rules (collected \"cssx\")))\n (clear-collected! \"cssx\")\n (raw! (str \"\")))" "lisp")) (p "This is upward communication through the render tree: " "a deeply nested component contributes a CSS rule, and the layout " "emits all accumulated rules as a single " (code "