spruce/list

Pure bullet and ordered list rendering.

Lists are rendered with an explicit Spruce context. Bullet lists use a Unicode bullet when color is supported and a deterministic ASCII marker when it is not. Ordered lists count from one at each nesting depth.

Types

The marker style used by the default enumerator.

pub type Kind {
  Bullet
  Ordered
}

Constructors

  • Bullet
  • Ordered

A list of labelled items.

pub opaque type List

Values

pub fn child(
  list_: List,
  label: String,
  children: List(String),
) -> List

Add a top-level item with one level of child labels.

pub fn enumerator(
  list_: List,
  enumerate: fn(Int, Int) -> String,
) -> List

Set a custom enumerator.

The function receives the one-based item index within the current depth and the one-based depth of the item being rendered. It should return the complete marker to place before that item’s first label line.

pub fn item(list_: List, label: String) -> List

Add a top-level item, preserving insertion order.

pub fn kind(list_: List, kind_: Kind) -> List

Set the default marker style for the list.

pub fn nested(list_: List, label: String, children: List) -> List

Add a top-level item whose children come from another list.

The nested list’s item tree is preserved, while the parent list’s kind and enumerator control rendering at every depth.

pub fn new() -> List

Build an empty bullet list.

pub fn render(sp: spruce.Spruce, list_: List) -> String

Render a list to a string.

Search Document