Skip to main content

Module code_block

Module code_block 

Source
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 El in the standard code-block surface chrome (sunken muted fill, themed border, rounded corners, SPACE_3 padding). Used by syntax-highlighter integrations that need the same chrome around a styled text_runs([...]) paragraph rather than a plain mono text leaf.