Documentation
¶
Overview ¶
Package render holds the markdown-and-code rendering machinery shared by every HTML-producing surface (internal/dex's static site, internal/ workbench's server-rendered pages): goldmark (GFM) plus chroma syntax-highlighting at render time, and the I-5 dispositions-block table renderer ("workbench and dex render the block as a table so humans never read raw YAML" — 05 §Workbench, I-5).
This package used to be two copies, one inside internal/dex (phase 12) and a second about to be written inside internal/workbench (phase 10). CLAUDE.md's "anything used by two or more packages lives in a shared internal/ package" rule applies directly, so the phase-12 code moved here verbatim (same goldmark/chroma configuration, same output bytes — dex's golden-fragment tests are the regression guard) and both surfaces now depend on this package instead of each other.
Index ¶
- func ChromaDarkCSS() string
- func ChromaLightCSS() string
- func DispositionsTable(ds []artifact.Disposition) template.HTML
- func HighlightCode(code, lang string) (template.HTML, error)
- func RenderBody(kind, class, body string) (string, error)
- func RenderMarkdown(body string) (string, error)
- func RenderMermaidBlock(source string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChromaDarkCSS ¶
func ChromaDarkCSS() string
ChromaDarkCSS is ChromaLightCSS's dark (github-dark) counterpart, meant to live inside a `@media (prefers-color-scheme: dark)` block.
func ChromaLightCSS ¶
func ChromaLightCSS() string
ChromaLightCSS returns the light (github) syntax-highlighting palette as CSS class rules (no surrounding HTML, no <style> tag). It is a pure, deterministic value: chroma's WriteCSS emits its rules in a fixed (token-type-sorted) order, so embedding this into a stylesheet keeps that stylesheet a pure function of the pinned style — preserving, not relaxing, the dex's byte-identical-rebuild property.
func DispositionsTable ¶
func DispositionsTable(ds []artifact.Disposition) template.HTML
DispositionsTable renders a feature spec's I-5 `dispositions:` block as an HTML table — "workbench and dex render the block as a table so humans never read raw YAML" (I-5) — one row per disposition: the board sticky id, its disposition value, and the value-specific detail (an incorporated entry's `where` anchor, rendered as a same-page link since I-5 requires it to resolve within the spec body; a contradicted entry's `note`; an open-question entry has neither). Returns "" for an empty block (component specs and draft feature specs with no board history carry none).
func HighlightCode ¶
HighlightCode renders code as a chroma-highlighted, class-based <pre><code>...</code></pre> block outside of any markdown document — used by pages that pretty-print a generated JSON blob rather than a markdown-authored code fence. Its colours, like the markdown path's, come from the served stylesheet's generated palettes (chromacss.go).
func RenderBody ¶
RenderBody renders an artifact body (the content after frontmatter) to a self-contained HTML fragment, dispatching on the artifact's kind and — for the diagram kind — its class discriminator. A "diagram" body is mermaid diagram source: it is emitted verbatim through the tier-badged mermaid seam (diagramtier.go) — never through goldmark, which would treat the diagram DSL as prose and collapse it into a `<p>graph TD ...</p>` (the user-reported defect). A diagram without class: proposal is illustrative BY CLASS (spec/illustrative-class dc-2) and wears the illustrative badge; a class: proposal wears the extractor-computed tier instead and is never painted illustrative (ac-2); any other class fails closed rather than guessing a tier (unknown enum values fail closed — and a mis-badged proposal would be the blending lie ac-2 exists to kill). Every other kind renders as markdown. Both HTML-producing surfaces (internal/dex's static pages and internal/workbench's server-rendered pages) route their artifact bodies through here, so the diagram special-case is defined once and cannot drift between them.
func RenderMarkdown ¶
RenderMarkdown renders body (an artifact's markdown body, sans frontmatter) to a self-contained HTML fragment.
func RenderMermaidBlock ¶
RenderMermaidBlock renders illustrative mermaid diagram source as the dc-1 badged figure: a `<figure data-diagram-tier="illustrative">` wrapping the `<pre class="mermaid">` the vendored client-side mermaid.js turns into an SVG diagram, plus the visible figcaption badge chip disclosing it as deterministically unverifiable (spec/illustrative-class ac-2). These are byte-for-byte the same wrapper the fenced ```mermaid special case (renderFencedCodeBlock) emits, so a non-proposal diagram-kind body and an inline fenced block render identically — the two illustrative locations of dc-2, one seam.
Types ¶
This section is empty.