Skip to main content

format_runs_from_spans

Function format_runs_from_spans 

Source
pub fn format_runs_from_spans(
    spans: &[ParsedSpan],
    is_code_block: bool,
) -> (String, Vec<FormatRun>)
Expand description

Translate a slice of parsed spans into (plain_text, format_runs).

One non-default span yields one FormatRun; spans with empty CharacterFormat (no decoration, no link, no code) emit no run, since an absent run means “inherit default formatting” in the new model. Adjacent runs with identical formats are coalesced via coalesce_in_place so the resulting vector satisfies debug_assert_well_formed.

Returns the concatenated plain_text of all spans and a sorted, non-overlapping, coalesced Vec<FormatRun>. Both safe to feed straight into the store under the dual-write bridge.