diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index ccc51c243ad..1505fe0369d 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1093,6 +1093,7 @@ fn push(s: &mut String, text_length: &mut usize, text: &str) { Tag::Emphasis => s.push_str(""), Tag::Strong => s.push_str(""), Tag::Paragraph => break, + Tag::Heading(..) => break, _ => {} }, Event::HardBreak | Event::SoftBreak => { diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index e2ce9ad23f4..ac3ea4c8c5f 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -235,6 +235,7 @@ fn t(input: &str, expect: &str) { t("code `let x = i32;` ...", "code let x = i32; …"); t("type `Type<'static>` ...", "type Type<'static> …"); t("# top header", "top header"); + t("# top header\n\nfollowed by a paragraph", "top header"); t("## header", "header"); t("first paragraph\n\nsecond paragraph", "first paragraph"); t("```\nfn main() {}\n```", "");