1
Fork 0

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.
This commit is contained in:
bors 2016-12-27 21:10:31 +00:00
commit 314c28b729
3 changed files with 16 additions and 15 deletions

View file

@ -1662,8 +1662,13 @@ fn document_full(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
}
fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
for stability in short_stability(item, cx, true) {
write!(w, "<div class='stability'>{}</div>", stability)?;
let stabilities = short_stability(item, cx, true);
if !stabilities.is_empty() {
write!(w, "<div class='stability'>")?;
for stability in stabilities {
write!(w, "{}", stability)?;
}
write!(w, "</div>")?;
}
Ok(())
}
@ -1862,7 +1867,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
String::new()
};
let text = format!("Deprecated{}{}", since, Markdown(&deprecated_reason));
stability.push(format!("<em class='stab deprecated'>{}</em>", text))
stability.push(format!("<div class='stab deprecated'>{}</div>", text))
};
if stab.level == stability::Unstable {
@ -1887,7 +1892,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
String::new()
};
let text = format!("Unstable{}{}", unstable_extra, Markdown(&unstable_reason));
stability.push(format!("<em class='stab unstable'>{}</em>", text))
stability.push(format!("<div class='stab unstable'>{}</div>", text))
};
} else if let Some(depr) = item.deprecation.as_ref() {
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
};
let text = format!("Deprecated{}{}", since, Markdown(&note));
stability.push(format!("<em class='stab deprecated'>{}</em>", text))
stability.push(format!("<div class='stab deprecated'>{}</div>", text))
}
stability