Skip to main content

code_block

Function code_block 

Source
pub fn code_block(s: impl Into<String>) -> El
Examples found in repository?
examples/long_form_content.rs (lines 61-65)
15fn fixture() -> El {
16    column([
17        h2("Long-form content widgets"),
18        paragraph(
19            "These primitives compose the markdown-shaped vocabulary an \
20             upcoming transformer will target. Each widget is plain \
21             Aetna — selectable text, themed surfaces, the same layout \
22             pass as everything else.",
23        ),
24        h3("Highlights"),
25        bullet_list(vec![
26            text_runs([
27                text("Bulleted lists with a hanging indent — wrapped lines align under "),
28                text("themselves").italic(),
29                text(", not under the marker."),
30            ]),
31            text_runs([
32                text("Inline runs work inside list items: "),
33                text("bold").bold(),
34                text(", "),
35                text("code").code(),
36                text(", "),
37                text("links").link("https://aetna.dev"),
38                text("."),
39            ]),
40            text("Nested blocks live inside an item by composing a column."),
41        ]),
42        blockquote([
43            paragraph(
44                "Markdown's shape is HTML's shape. The Aetna widget kit \
45                 already mirrors most of that shape, so the transformer \
46                 mostly hands events to existing constructors.",
47            ),
48            paragraph("— Aetna design notes").muted(),
49        ]),
50        h3("Setup steps"),
51        numbered_list(vec![
52            text("Add `aetna-markdown` to the workspace."),
53            text_runs([
54                text("Pull in "),
55                text("pulldown-cmark").code(),
56                text(" with the GFM features the project actually uses."),
57            ]),
58            text("Wire the transformer through the existing widget kit — paragraph, list, blockquote, code_block, divider, table."),
59        ]),
60        h3("Example fenced block"),
61        code_block(
62            "fn render(md: &str) -> El {\n    \
63                 // pulldown-cmark events -> El\n    \
64                 todo!(\"phase 2\")\n}",
65        ),
66    ])
67    .gap(tokens::SPACE_4)
68    .padding(tokens::SPACE_7)
69    .width(Size::Fixed(640.0))
70}