diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 13a31c557021d..d9bbc957c8a2d 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -237,15 +237,23 @@ impl<'a> fmt::Display for WhereClause<'a> { clause.push(','); } } + + if end_newline { + //add a space so stripping
tags and breaking spaces still renders properly + if f.alternate() { + clause.push(' '); + } else { + clause.push_str(" "); + } + } + if !f.alternate() { clause.push_str(""); let padding = repeat(" ").take(indent + 4).collect::(); clause = clause.replace("
", &format!("
{}", padding)); clause.insert_str(0, &repeat(" ").take(indent.saturating_sub(1)) .collect::()); - if end_newline { - clause.push(' '); - } else { + if !end_newline { clause.insert_str(0, "
"); } }