module

TUI::Markdown::Wrap

Pure greedy word-wrap over a sequence of styled InlineRuns — no dependency on Buffer/Term/the parser, so it's spec'd as a standalone function. Breaks only at whitespace boundaries; a single word wider than width is hard-broken into width-sized chunks (better than overflowing the buffer). Styling is preserved per run across a wrap point: a run is never merged with a NEIGHBORING run of a different style, so a bold word can never bleed its style onto adjacent plain text regardless of where the line happens to break.

Class methods

wrap(runs : Array(InlineRun), width : Int32) : Array(Array(InlineRun))

ameba:disable Metrics/CyclomaticComplexity

Source