inline_runs/
inline_runs.rs1use aetna_core::prelude::*;
17
18fn fixture() -> El {
19 column([
20 h2("Inline runs"),
21 text_runs([
22 text("Aetna's attributed-text path lets you compose runs with "),
23 text("bold").bold(),
24 text(", "),
25 text("italic").italic(),
26 text(", "),
27 text("colored").color(tokens::DESTRUCTIVE),
28 text(", and "),
29 text("inline code").code(),
30 text(" segments inside one wrapping paragraph."),
31 hard_break(),
32 text("Hard breaks act like ").muted(),
33 text("<br>").code(),
34 text(" — they end the current line without breaking out of the run.").muted(),
35 ])
36 .wrap_text()
37 .width(Size::Fill(1.0))
38 .height(Size::Hug),
39 paragraph(
40 "All of the above flows through one cosmic-text rich-text shape — \
41 wrapping decisions cross run boundaries the way real prose wraps.",
42 )
43 .muted(),
44 ])
45 .gap(tokens::SPACE_4)
46 .padding(tokens::SPACE_7)
47 .width(Size::Fixed(640.0))
48}
49
50fn main() -> std::io::Result<()> {
51 let mut root = fixture();
52
53 let viewport = Rect::new(0.0, 0.0, 640.0, 360.0);
54 let bundle = render_bundle(&mut root, viewport);
55
56 let out_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("out");
57 let written = write_bundle(&bundle, &out_dir, "inline_runs")?;
58 for p in &written {
59 println!("wrote {}", p.display());
60 }
61
62 if !bundle.lint.findings.is_empty() {
63 eprintln!("\nlint findings ({}):", bundle.lint.findings.len());
64 eprint!("{}", bundle.lint.text());
65 }
66
67 Ok(())
68}