Skip to content

hue images & diagrams — Feature Requirements (raster, mermaid/graphviz, LaTeX)

Status: planned · Date: 2026-07-23 · Scope: rendering real media in the markdown preview — raster images (![](…)), diagram fences (mermaid, graphviz/dot, …), and LaTeX math (inline + block) — across the interactive backends. All three flow through one media-block mechanism in the wrapped-line model, displayed per backend (GUI texture · terminal graphics protocol · HTML <img>/<svg>).

NOTE

Forward-looking — every row is not started. Today an image inline renders as a placeholder glyph (gui.md MDP 󰥶), no diagram/math fence is special-cased, and only ```ansi fences get non-code treatment (MDP12). Status legend and IDs: see the overview.

Design & rationale

Images, diagrams, and math differ only in how pixels are produced; how they are placed and shown is one shared mechanism:

  • Producers turn a source into displayable pixels/markup: a raster image file is decoded (IMG); a diagram fence is rendered by an external engine to SVG/PNG (DGM); a math expression is typeset (MTH).
  • The media block (MDB) places the result: it reserves N cell-rows in the wrapped PreviewLine[] (RND2) sized to the media's aspect at the available width, and each backend paints it — a raylib texture (GUI), a terminal graphics protocol (TUI), or native <img>/<svg> (HTML).

Everything degrades to alt text + the source (the totality law), and diagram rendering — which shells out to external engines — is opt-in for security.

Media block & display (MDB)

IDRequirementStatusTraces to
MDB1Images / diagrams / block-math must be a media block in the wrapped PreviewLine[] — reserving N cell-rows sized to the media's aspect at the content width; it scrolls by visual row like any block.not startedproposed media block in gui_preview.d
MDB2GUI — the decoded media must draw as a raylib texture over the reserved block, scaled to fit the content width (aspect preserved), loaded and cached on demand.not startedraylib LoadTexture/DrawTexture in gui.d
MDB3TUI — media must display via a terminal graphics protocol (kitty graphics / sixel / iTerm2 inline images), detected at startup (tui.md TCP1); unsupported → a placeholder box + alt text.not startedproposed graphics-protocol emitter; memory terminal-image-protocol-detection
MDB4HTML — media must emit native markup: <img> for raster, inline/linked <svg> for diagrams, KaTeX/MathJax (or pre-rendered) for math.not startedapp.d HTML branch
MDB5Every media block must carry alt text / a caption and degrade to it (plus the source path/fence) when the media can't be decoded, rendered, or displayed — never a crash, never a blank (totality).not starteddegradation (RND5)
MDB6Media must reflow on width/resize — recompute the block's cell-rows and re-scale — like the rest of the layout (WRP4).not startedrelayout on width change

Raster images (IMG)

IDRequirementStatusTraces to
IMG1Markdown ![alt](path) and image files must load local raster images (PNG / JPG / GIF / WebP) and display via MDB — replacing today's placeholder glyph (gui.md MDP).not startedMdDoc image inlines; raylib image load
IMG2SVG images must be rasterized (an SVG rasterizer) to pixels for the GUI/TUI at the display size; HTML uses the SVG directly.not startedproposed SVG rasterizer
IMG3Remote images (http(s)://) must be opt-in (a flag, off by default) for privacy/security; the default shows alt text + the URL.not startedproposed --remote-images gate
IMG4A decode failure or unsupported format must fall back to alt text + path (MDB5).not starteddecode failure → MDB5
IMG5Image diff — a changed image in a diff/PR session (DVS4) renders old and new side by side through the media-block mechanism (GUI texture · terminal graphics protocol · HTML <img> pair) with a dimensions/byte-size delta line; researched (WinMerge/diffy precedent), deferred.researched/not startedMDB*; diff-view.md; research: WinMerge

Diagrams (DGM)

IDRequirementStatusTraces to
DGM1Fenced diagram blocks — ```mermaid, ```dot/graphviz, ```plantuml, … — must render to an image/SVG via a diagram engine and display via MDB.not startedfence dispatch (cf. MDP12)
DGM2Rendering must be cached, keyed by (language, content, size), so re-layout/scroll never re-renders; each expensive render happens once.not startedproposed render cache
DGM3Diagram engines are external processes (mermaid-cli, graphviz dot, …); invoking them on document content is a trust boundary, so it must be opt-in (a flag / allowlist), off by default, with a resolvable engine per language.not startedproposed --diagrams gate + engine resolution
DGM4An unknown/unsupported diagram language, a missing engine, or a render error must fall back to an ordinary highlighted code block (today's behavior), not an error.not startedfallback → code fence

Math / LaTeX (MTH)

IDRequirementStatusTraces to
MTH1Block math```math fences and $$…$$ — must typeset to a math image/SVG (a KaTeX/TeX engine) and display via MDB.not startedmath engine → MDB
MTH2Inline math$…$ — must render inline (a small inline image/box within the text line) or fall back to the raw LaTeX with light styling.not startedinline media in a text run
MTH3HTML must use KaTeX/MathJax markup (or pre-rendered) rather than a raster where practical; GUI/TUI use the rasterized result.not startedMDB4; HTML branch

Milestones

MilestoneScopeStatusRequirements
I0Media-block model + GUI raster imagesnot startedMDB1/MDB2/MDB5/6, IMG1
I1SVG rasterization + remote-image opt-innot startedIMG2, IMG3
I2TUI terminal graphics protocolnot startedMDB3
I3Diagrams (mermaid/dot) — cache + opt-in enginesnot startedDGM*
I4Math (block + inline)not startedMTH*
I5HTML native <img>/<svg>/KaTeXnot startedMDB4, MTH3

Relationship to existing specs

PieceRole
gui.md MDP (image 󰥶 placeholder), FNT7/DEF8today's placeholder; the color-emoji rasterizer gap is adjacent
gui.md MDP12 (```ansi fence decode)precedent for special-casing a fence — diagrams/math extend it
tui.md TCP1 (caps)detects the terminal graphics protocol (MDB3)
apps/terminal image support; memory terminal-image-protocol-detectionprotocol grounding for MDB3
sparkles:syntax MdDoc (image inlines, fence blocks)media source detection

GUI requirements · TUI requirements · Overview