Fix empty code blocks: rename ~docs/code param, fix batched IO dispatch
Two bugs caused code blocks to render empty across the site: 1. ~docs/code component had parameter named `code` which collided with the HTML <code> tag name. Renamed to `src` and updated all 57 callers. Added font-mono class for explicit monospace. 2. Batched IO dispatch in ocaml_bridge.py only skipped one leading number (batch ID) but the format has two (epoch + ID): (io-request EPOCH ID "name" args...). Changed to skip all leading numbers so the string name is correctly found. This fixes highlight and other batchable helpers returning empty results. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -84,19 +84,19 @@
|
||||
(p (code "provide") " creates a named scope with a value and an empty accumulator. "
|
||||
"The body expressions execute with the scope active. When the body completes, "
|
||||
"the scope is popped.")
|
||||
(~docs/code :code (highlight "(provide name value\n body...)\n\n;; Example: theme context\n(provide \"theme\" {:primary \"violet\"}\n (h1 \"Title\") ;; can read (context \"theme\")\n (p \"Body\")) ;; scope active for all children" "lisp"))
|
||||
(~docs/code :src (highlight "(provide name value\n body...)\n\n;; Example: theme context\n(provide \"theme\" {:primary \"violet\"}\n (h1 \"Title\") ;; can read (context \"theme\")\n (p \"Body\")) ;; scope active for all children" "lisp"))
|
||||
(p (code "provide") " is a special form, not a function — the body is evaluated "
|
||||
"inside the scope, not before it."))
|
||||
|
||||
(~docs/subsection :title "context"
|
||||
(p "Reads the value from the nearest enclosing " (code "provide") " with the given name. "
|
||||
"Errors if no provider and no default given.")
|
||||
(~docs/code :code (highlight "(provide \"theme\" {:primary \"violet\" :font \"serif\"}\n (get (context \"theme\") :primary)) ;; → \"violet\"\n\n;; With default (no error when missing):\n(context \"theme\" {:primary \"stone\"}) ;; → {:primary \"stone\"}" "lisp")))
|
||||
(~docs/code :src (highlight "(provide \"theme\" {:primary \"violet\" :font \"serif\"}\n (get (context \"theme\") :primary)) ;; → \"violet\"\n\n;; With default (no error when missing):\n(context \"theme\" {:primary \"stone\"}) ;; → {:primary \"stone\"}" "lisp")))
|
||||
|
||||
(~docs/subsection :title "emit!"
|
||||
(p "Appends a value to the nearest enclosing provider's accumulator. "
|
||||
"Tolerant: returns nil silently when no provider exists.")
|
||||
(~docs/code :code (highlight "(provide \"scripts\" nil\n (emit! \"scripts\" \"analytics.js\")\n (emit! \"scripts\" \"charts.js\")\n ;; accumulator now has both scripts\n )\n\n;; Outside any provider — silently does nothing:\n(emit! \"scripts\" \"orphan.js\") ;; → nil, no error" "lisp"))
|
||||
(~docs/code :src (highlight "(provide \"scripts\" nil\n (emit! \"scripts\" \"analytics.js\")\n (emit! \"scripts\" \"charts.js\")\n ;; accumulator now has both scripts\n )\n\n;; Outside any provider — silently does nothing:\n(emit! \"scripts\" \"orphan.js\") ;; → nil, no error" "lisp"))
|
||||
(p "Tolerance is critical. Spreads emit into " (code "\"element-attrs\"")
|
||||
" — but a spread might be evaluated in a fragment, a " (code "begin") " block, or a "
|
||||
(code "map") " call where no element provider exists. "
|
||||
@@ -105,7 +105,7 @@
|
||||
(~docs/subsection :title "emitted"
|
||||
(p "Returns the list of values emitted into the nearest provider with the given name. "
|
||||
"Empty list if no provider.")
|
||||
(~docs/code :code (highlight "(provide \"scripts\" nil\n (emit! \"scripts\" \"a.js\")\n (emit! \"scripts\" \"b.js\")\n (emitted \"scripts\")) ;; → (\"a.js\" \"b.js\")" "lisp"))))
|
||||
(~docs/code :src (highlight "(provide \"scripts\" nil\n (emit! \"scripts\" \"a.js\")\n (emit! \"scripts\" \"b.js\")\n (emitted \"scripts\")) ;; → (\"a.js\" \"b.js\")" "lisp"))))
|
||||
|
||||
;; =====================================================================
|
||||
;; II. Two directions, one mechanism
|
||||
@@ -166,7 +166,7 @@
|
||||
|
||||
(p "For " (code "emit!") ", this means emissions go to the " (em "nearest") " provider. "
|
||||
"A spread inside a nested element emits to that element, not an ancestor.")
|
||||
(~docs/code :code (highlight ";; Nested elements = nested providers\n(div ;; provider A\n (span ;; provider B\n (make-spread {:class \"inner\"})) ;; emits to B\n (make-spread {:class \"outer\"})) ;; emits to A\n;; → <div class=\"outer\"><span class=\"inner\"></span></div>" "lisp")))
|
||||
(~docs/code :src (highlight ";; Nested elements = nested providers\n(div ;; provider A\n (span ;; provider B\n (make-spread {:class \"inner\"})) ;; emits to B\n (make-spread {:class \"outer\"})) ;; emits to A\n;; → <div class=\"outer\"><span class=\"inner\"></span></div>" "lisp")))
|
||||
|
||||
;; =====================================================================
|
||||
;; V. Across all adapters
|
||||
|
||||
Reference in New Issue
Block a user