Skip to main content

push_html_text

Function push_html_text 

Source
pub fn push_html_text(
    out: &mut String,
    text: &str,
    after_space: bool,
    ends_line: bool,
    escape: impl Fn(&str) -> String,
    line_break: &str,
)
Expand description

Write text, a run of a paragraph’s text, into out as HTML: each of its lines (it separates them with LINE_SEPARATOR) escaped by escape, the lines joined by line_break, and a line whose whitespace an HTML reader would collapse put in a <span style="white-space: pre-wrap">, where browsers, Qt and this crate’s own HTML reader keep it as it is.

A line is wrapped when it holds a tab or another HTML space but the plain space, two spaces in a row, a space at its start when after_space (the text before it on its line ends in whitespace, or the line starts with it), or a space at its end when ends_line (its line ends with it). Written bare, a tab came back as a space and a writer’s double space as one, so the HTML of a text read back was not the HTML it had been read from. Text an HTML reader keeps as it is goes out bare, as before.

after_space for the next run is html_text_ends_open.