Skip to content

Commit 314c28b

Browse files
committed
Auto merge of #38329 - ollie27:rustdoc_stab_em_div, r=steveklabnik
rustdoc: Fix invalid HTML in stability notices `em` tags cannot contain `p` tags so use `div`s instead of `em`s as the Markdown will create `p` tags.
2 parents 82801b5 + e395fd1 commit 314c28b

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/librustdoc/html/render.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,8 +1662,13 @@ fn document_full(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
16621662
}
16631663

16641664
fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
1665-
for stability in short_stability(item, cx, true) {
1666-
write!(w, "<div class='stability'>{}</div>", stability)?;
1665+
let stabilities = short_stability(item, cx, true);
1666+
if !stabilities.is_empty() {
1667+
write!(w, "<div class='stability'>")?;
1668+
for stability in stabilities {
1669+
write!(w, "{}", stability)?;
1670+
}
1671+
write!(w, "</div>")?;
16671672
}
16681673
Ok(())
16691674
}
@@ -1862,7 +1867,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
18621867
String::new()
18631868
};
18641869
let text = format!("Deprecated{}{}", since, Markdown(&deprecated_reason));
1865-
stability.push(format!("<em class='stab deprecated'>{}</em>", text))
1870+
stability.push(format!("<div class='stab deprecated'>{}</div>", text))
18661871
};
18671872

18681873
if stab.level == stability::Unstable {
@@ -1887,7 +1892,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
18871892
String::new()
18881893
};
18891894
let text = format!("Unstable{}{}", unstable_extra, Markdown(&unstable_reason));
1890-
stability.push(format!("<em class='stab unstable'>{}</em>", text))
1895+
stability.push(format!("<div class='stab unstable'>{}</div>", text))
18911896
};
18921897
} else if let Some(depr) = item.deprecation.as_ref() {
18931898
let note = if show_reason && !depr.note.is_empty() {
@@ -1902,7 +1907,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
19021907
};
19031908

19041909
let text = format!("Deprecated{}{}", since, Markdown(&note));
1905-
stability.push(format!("<em class='stab deprecated'>{}</em>", text))
1910+
stability.push(format!("<div class='stab deprecated'>{}</div>", text))
19061911
}
19071912

19081913
stability

src/librustdoc/html/static/rustdoc.css

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 6 deletions
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)