Expand description
Code block — surface-tinted monospace block for fenced code.
Mirrors HTML’s <pre><code> shape: a bordered, rounded surface that
wraps a multi-line monospace body. The body uses the mono font path
at TEXT_SM size and does not wrap — long lines extend horizontally
rather than reflowing, the same convention shadcn’s typography uses
for fenced code (overflow-x-auto). Author wraps the result in
scroll([...]) for horizontal scroll if desired; that integration is
out of scope for this primitive.
Two entry points: code_block takes a verbatim string and renders
it as one mono text leaf, while code_block_chrome takes any
pre-built body El (typically a styled text_runs paragraph
produced by a syntax highlighter) and applies the same surface
chrome — used by aetna-markdown to render highlighted fenced code
without duplicating the chrome tokens.
use aetna_core::prelude::*;
code_block("fn main() {\n println!(\"hi\");\n}")Functions§
- code_
block - code_
block_ chrome - Wrap an author-supplied body
Elin the standard code-block surface chrome (sunken muted fill, themed border, rounded corners,SPACE_3padding). Used by syntax-highlighter integrations that need the same chrome around a styledtext_runs([...])paragraph rather than a plain mono text leaf.