W3: presentation fixes — delimiters, line breaks, mermaid

- src/core/math-delims.ts: pure preprocessing for the \(...\)/\[...\] math
  contract — balanced delimiters rewrite to the two-dollar forms remark-math
  parses ($ is never math). Skips code fences/spans, escaped delimiters, and
  leaves unbalanced (mid-stream) delimiters untouched. Display math renders
  as a block: mid-paragraph gets blank-line padding; indented (list items)
  degrades to inline so list continuations don't half-parse.
- message.tsx: transform in the render path (children-memoized); math plugin
  now singleDollarTextMath: false — the currency hazard dies structurally.
  remark-breaks via the cjk remarkPluginsAfter slot (the bare remarkPlugins
  prop would replace the [remark-gfm, codeMeta] defaults).
- mermaid: dark theme + sans font via Streamdown's mermaid prop; dark-styled
  error fallback (components/mermaid-error.tsx) with error, source in
  <details>, and retry.
- globals.css (appended): @source for streamdown dist — its internal UI
  chrome (code blocks, mermaid containers, tables) was entirely unstyled
  because Tailwind v4 never scans node_modules; --color-sidebar → card; wide
  mermaid SVGs capped to the column; .katex-display scrolls.
- tests/render-markdown.test.tsx: 26 tests (transform unit + render). The
  math describe block in render-cards.test.tsx is updated to the new
  contract ($...$ now renders as literal text — pinned).
This commit is contained in:
Amos
2026-08-22 09:38:54 +03:00
parent 866352cb65
commit ef488224bc
6 changed files with 593 additions and 33 deletions
+30
View File
@@ -127,3 +127,33 @@ body {
.dock-variant {
animation: dock-variant-in 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* ============================================================
* W3 — presentation fixes (appended 2026-08-22)
* ============================================================ */
/* Streamdown's internal UI chrome (code blocks, tables, mermaid containers,
copy/download buttons) is styled with Tailwind utilities living in its dist
* bundle. Tailwind v4 never scans node_modules, so without this line those
* classes are dead — code blocks and mermaid containers rendered unstyled.
* (Streamdown README, "Tailwind CSS setup".) */
@source "../node_modules/streamdown/dist/*.js";
/* Token the streamdown utilities reference (code-block/mermaid chrome uses
* bg-sidebar / border-sidebar): map it onto the app's card surface. */
@theme inline {
--color-sidebar: var(--card);
}
/* Mermaid diagrams: keep wide charts inside the content column. Mermaid
* inlines a px max-width on the svg, so !important is required to win. */
[data-streamdown="mermaid"] svg {
max-width: 100% !important;
height: auto !important;
}
/* Display math: long equations scroll instead of overflowing the column. */
.katex-display {
overflow-x: auto;
overflow-y: hidden;
}