Skip to main content

render_to_string

Function render_to_string 

Source
pub fn render_to_string(arena: &Arena, root_id: u32, width: u16) -> String
Expand description

Render the arena tree rooted at root_id to a plain-frame string.

Orchestration (mirrors renderer.ts + render-to-string.ts):

  1. Build a fresh TaffyEngine (engine-per-call; see module docs).
  2. Walk the arena: create taffy nodes, apply styles, set text measures.
  3. calculate(root, width, MAX_HEIGHT) — unconstrained height per ink.
  4. Walk arena again: render each node into a Grid.
  5. Return grid.get().0 (the trimmed frame string).

The returned string matches ink’s renderToString output for unstyled content (no SGR transformers, no static nodes).