Function textwrap::unfill [−][src]
pub fn unfill<'a>(text: &'a str) -> (String, Options<'a, HyphenSplitter>)
Expand description
Unpack a paragraph of already-wrapped text.
This function attempts to recover the original text from a single
paragraph of text produced by the fill
function. This means
that it turns
textwrap: a small library for wrapping text.
back into
textwrap: a small library for wrapping text.
In addition, it will recognize a common prefix among the lines.
The prefix of the first line is returned in
Options::initial_indent
and the prefix (if any) of the the
other lines is returned in Options::subsequent_indent
.
In addition to ' '
, the prefixes can consist of characters used
for unordered lists ('-'
, '+'
, and '*'
) and block quotes
('>'
) in Markdown as well as characters often used for inline
comments ('#'
and '/'
).
The text must come from a single wrapped paragraph. This means
that there can be no "\n\n"
within the text.
Examples
use textwrap::unfill; let (text, options) = unfill("\ * This is an example of a list item. "); assert_eq!(text, "This is an example of a list item.\n"); assert_eq!(options.initial_indent, "* "); assert_eq!(options.subsequent_indent, " ");