Skip to main content

without_spacers

Function without_spacers 

Source
fn without_spacers(html: &str) -> String
Expand description

Spacer blocks and runs of line breaks, which layouts use for room, taken out in one pass: a block is dropped as its end is written, when nothing but a space stands in it, so a block left empty by the spacers it held goes too (<div><p></p></div>), and a third line break in a row goes. Done by replacing them over the whole text until none was left, the work grew with the square of the nesting: 8,000 empty blocks in one another took seconds.