wrap
A word-wrap function that preserves existing line breaks. Expects that existing line breaks are posix newlines. Preserve all white space except added line breaks consume the space on which they break the line. Don't wrap long words, thus the output text may have lines longer than width.
def wrap(
text: string,
width: integer
) - > string
A word-wrap function that preserves existing line breaks. Expects that existing line breaks are posix newlines. Preserve all white space except added line breaks consume the space on which they break the line. Don't wrap long words, thus the output text may have lines longer than width.
Parameters
| Name | Type | Description |
|---|---|---|
| text | string | The input string to be wrapped, expected to use POSIX-style newlines. |
| width | integer | The maximum number of characters allowed per line before a wrap is attempted. |
Returns
| Type | Description |
|---|---|
string | The wrapped text string with original line breaks preserved and new ones inserted at the specified width. |