A diagram's label, from its source text to lines of cells. A label is measured in display columns, since a painter writes it as terminal text.
| Name | Signature |
|---|---|
| decode | decode(raw) -> lines |
| width | width(lines) -> cols |
| wrap | wrap(lines, max_cols) -> lines |
decode(
raw) ->lines
Turn a label's source text into its lines
Strips one pair of double quotes, and the backticks of a markdown string
inside them. Reads <br>, <br/> and a newline as a line break, and an
entity code (#quot;, #35;) as its character. An unknown code stays as
written. Each line comes back trimmed, with runs of blanks as one space.
A label of blanks alone is one empty line.
No control character comes out. A raw one is dropped, but for a tab, a
newline and the other blanks, which read as blanks. An entity code for a
control character (#27;, #155;) or a surrogate stays as written.
width(
lines) ->cols
Measure the widest line of a label
wrap(
lines,max_cols) ->lines
Wrap a label's lines to a width
Breaks each line at its spaces so that no line is wider than max_cols
columns. A word wider than that is cut at the column. A character wider
than max_cols stays whole, on a line of its own. A line that fits comes
back as it is.