Skip to content

Commit b3eda5f

Browse files
committed
Replace nbsp in all rustdoc code blocks
1 parent f5c3dfd commit b3eda5f

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/librustdoc/html/format.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ impl clean::GenericParamDef {
208208
if f.alternate() {
209209
write!(f, ": {:#}", print_generic_bounds(bounds, cx))?;
210210
} else {
211-
write!(f, ": {}", print_generic_bounds(bounds, cx))?;
211+
write!(f, ": {}", print_generic_bounds(bounds, cx))?;
212212
}
213213
}
214214

215215
if let Some(ref ty) = default {
216216
if f.alternate() {
217217
write!(f, " = {:#}", ty.print(cx))?;
218218
} else {
219-
write!(f, " = {}", ty.print(cx))?;
219+
write!(f, " = {}", ty.print(cx))?;
220220
}
221221
}
222222

@@ -226,14 +226,14 @@ impl clean::GenericParamDef {
226226
if f.alternate() {
227227
write!(f, "const {}: {:#}", self.name, ty.print(cx))?;
228228
} else {
229-
write!(f, "const {}: {}", self.name, ty.print(cx))?;
229+
write!(f, "const {}: {}", self.name, ty.print(cx))?;
230230
}
231231

232232
if let Some(default) = default {
233233
if f.alternate() {
234234
write!(f, " = {:#}", default)?;
235235
} else {
236-
write!(f, " = {}", default)?;
236+
write!(f, " = {}", default)?;
237237
}
238238
}
239239

@@ -354,12 +354,12 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
354354
let mut br_with_padding = String::with_capacity(6 * indent + 28);
355355
br_with_padding.push_str("<br>");
356356
for _ in 0..indent + 4 {
357-
br_with_padding.push_str("&nbsp;");
357+
br_with_padding.push_str(" ");
358358
}
359359
let where_preds = where_preds.to_string().replace("<br>", &br_with_padding);
360360

361361
if ending == Ending::Newline {
362-
let mut clause = "&nbsp;".repeat(indent.saturating_sub(1));
362+
let mut clause = " ".repeat(indent.saturating_sub(1));
363363
write!(clause, "<span class=\"where fmt-newline\">where{where_preds},</span>")?;
364364
clause
365365
} else {
@@ -368,7 +368,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
368368
format!("<br><span class=\"where\">where{where_preds}</span>")
369369
} else {
370370
let mut clause = br_with_padding;
371-
clause.truncate(clause.len() - 4 * "&nbsp;".len());
371+
clause.truncate(clause.len() - 4 * " ".len());
372372
write!(clause, "<span class=\"where\">where{where_preds}</span>")?;
373373
clause
374374
}
@@ -1392,8 +1392,8 @@ impl clean::FnDecl {
13921392

13931393
let declaration_len = header_len + args_plain.len() + arrow_plain.len();
13941394
let output = if declaration_len > 80 {
1395-
let full_pad = format!("<br>{}", "&nbsp;".repeat(indent + 4));
1396-
let close_pad = format!("<br>{}", "&nbsp;".repeat(indent));
1395+
let full_pad = format!("<br>{}", " ".repeat(indent + 4));
1396+
let close_pad = format!("<br>{}", " ".repeat(indent));
13971397
format!(
13981398
"({pad}{args}{close}){arrow}",
13991399
pad = if self.inputs.values.is_empty() { "" } else { &full_pad },
@@ -1612,7 +1612,7 @@ impl clean::TypeBinding {
16121612
if f.alternate() {
16131613
write!(f, ": {:#}", print_generic_bounds(bounds, cx))?;
16141614
} else {
1615-
write!(f, ":&nbsp;{}", print_generic_bounds(bounds, cx))?;
1615+
write!(f, ": {}", print_generic_bounds(bounds, cx))?;
16161616
}
16171617
}
16181618
}

src/librustdoc/html/render/print_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
11791179
fn print_tuple_struct_fields(w: &mut Buffer, cx: &Context<'_>, s: &[clean::Item]) {
11801180
for (i, ty) in s.iter().enumerate() {
11811181
if i > 0 {
1182-
w.write_str(",&nbsp;");
1182+
w.write_str(", ");
11831183
}
11841184
match *ty.kind {
11851185
clean::StrippedItem(box clean::StructFieldItem(_)) => w.write_str("_"),
@@ -1327,7 +1327,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
13271327
"<div class=\"sub-variant-field\">\
13281328
<span id=\"{id}\" class=\"small-section-header\">\
13291329
<a href=\"#{id}\" class=\"anchor field\">§</a>\
1330-
<code>{f}:&nbsp;{t}</code>\
1330+
<code>{f}: {t}</code>\
13311331
</span>",
13321332
id = id,
13331333
f = field.name.unwrap(),

src/librustdoc/html/static/css/rustdoc.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ h4.code-header {
182182
font-weight: 600;
183183
margin: 0;
184184
padding: 0;
185+
white-space: pre;
185186
}
186187

187188
#crate-search,
@@ -639,6 +640,7 @@ pre, .rustdoc.source .example-wrap {
639640
.fn .where,
640641
.where.fmt-newline {
641642
display: block;
643+
white-space: pre;
642644
font-size: 0.875rem;
643645
}
644646

0 commit comments

Comments
 (0)