Skip to content

Commit e395fd1

Browse files
committed
rustdoc: Fix invalid HTML in stability notices
`em` tags cannot contain `p` tags so just use a `div` instead.
1 parent 368e092 commit e395fd1

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/librustdoc/html/render.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1655,8 +1655,13 @@ fn document_full(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
16551655
}
16561656

16571657
fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
1658-
for stability in short_stability(item, cx, true) {
1659-
write!(w, "<div class='stability'>{}</div>", stability)?;
1658+
let stabilities = short_stability(item, cx, true);
1659+
if !stabilities.is_empty() {
1660+
write!(w, "<div class='stability'>")?;
1661+
for stability in stabilities {
1662+
write!(w, "{}", stability)?;
1663+
}
1664+
write!(w, "</div>")?;
16601665
}
16611666
Ok(())
16621667
}
@@ -1855,7 +1860,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
18551860
String::new()
18561861
};
18571862
let text = format!("Deprecated{}{}", since, Markdown(&deprecated_reason));
1858-
stability.push(format!("<em class='stab deprecated'>{}</em>", text))
1863+
stability.push(format!("<div class='stab deprecated'>{}</div>", text))
18591864
};
18601865

18611866
if stab.level == stability::Unstable {
@@ -1880,7 +1885,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
18801885
String::new()
18811886
};
18821887
let text = format!("Unstable{}{}", unstable_extra, Markdown(&unstable_reason));
1883-
stability.push(format!("<em class='stab unstable'>{}</em>", text))
1888+
stability.push(format!("<div class='stab unstable'>{}</div>", text))
18841889
};
18851890
} else if let Some(depr) = item.deprecation.as_ref() {
18861891
let note = if show_reason && !depr.note.is_empty() {
@@ -1895,7 +1900,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
18951900
};
18961901

18971902
let text = format!("Deprecated{}{}", since, Markdown(&note));
1898-
stability.push(format!("<em class='stab deprecated'>{}</em>", text))
1903+
stability.push(format!("<div class='stab deprecated'>{}</div>", text))
18991904
}
19001905

19011906
stability

src/librustdoc/html/static/rustdoc.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -523,20 +523,20 @@ body.blur > :not(#help) {
523523
padding: 20px;
524524
}
525525

526-
em.stab {
527-
display: inline-block;
526+
.stab {
527+
display: table;
528528
border-width: 1px;
529529
border-style: solid;
530530
padding: 3px;
531531
margin-bottom: 5px;
532532
font-size: 90%;
533-
font-style: normal;
534533
}
535-
em.stab p {
534+
.stab p {
536535
display: inline;
537536
}
538537

539538
.module-item .stab {
539+
display: inline;
540540
border-width: 0;
541541
padding: 0;
542542
margin: 0;

src/librustdoc/html/static/styles/main.css

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.t
3030
background-color: white;
3131
}
3232

33-
div.stability > em > code {
34-
background-color: initial;
35-
}
36-
3733
.docblock code, .docblock-short code {
3834
background-color: #F5F5F5;
3935
}
@@ -129,5 +125,5 @@ a.test-arrow {
129125
background-color: white;
130126
}
131127

132-
em.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
133-
em.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
128+
.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
129+
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }

0 commit comments

Comments
 (0)