Skip to content

Commit ccd550e

Browse files
committed
[rustdoc] Wrap code blocks in <code> tag
1 parent 0035d9d commit ccd550e

File tree

6 files changed

+315
-267
lines changed

6 files changed

+315
-267
lines changed

src/librustdoc/html/highlight.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ fn write_header(out: &mut Buffer, class: Option<&str>, extra_content: Option<Buf
6565
out.push_buffer(extra);
6666
}
6767
if let Some(class) = class {
68-
writeln!(out, "<pre class=\"rust {}\">", class);
68+
write!(out, "<pre class=\"rust {}\">", class);
6969
} else {
70-
writeln!(out, "<pre class=\"rust\">");
70+
write!(out, "<pre class=\"rust\">");
7171
}
72+
write!(out, "<code>");
7273
}
7374

7475
/// Convert the given `src` source code into HTML by adding classes for highlighting.
@@ -101,7 +102,7 @@ fn write_code(
101102
}
102103

103104
fn write_footer(out: &mut Buffer, playground_button: Option<&str>) {
104-
writeln!(out, "</pre>{}</div>", playground_button.unwrap_or_default());
105+
writeln!(out, "</code></pre>{}</div>", playground_button.unwrap_or_default());
105106
}
106107

107108
/// How a span of text is classified. Mostly corresponds to token kinds.

src/librustdoc/html/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
234234
return Some(Event::Html(
235235
format!(
236236
"<div class=\"example-wrap\">\
237-
<pre class=\"language-{}\">{}</pre>\
237+
<pre class=\"language-{}\"><code>{}</code></pre>\
238238
</div>",
239239
lang,
240240
Escape(&text),

0 commit comments

Comments
 (0)