Skip to content

Commit e40b3d6

Browse files
committed
Treat header as first paragraph for shortened markdown descriptions
"The Rust Standard LibraryThe Rust Standard Library is the …" is an awful description.
1 parent 3a5d45f commit e40b3d6

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/librustdoc/html/markdown.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool)
10931093
Tag::Emphasis => s.push_str("</em>"),
10941094
Tag::Strong => s.push_str("</strong>"),
10951095
Tag::Paragraph => break,
1096+
Tag::Heading(..) => break,
10961097
_ => {}
10971098
},
10981099
Event::HardBreak | Event::SoftBreak => {

src/librustdoc/html/markdown/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ fn test_short_markdown_summary() {
235235
t("code `let x = i32;` ...", "code <code>let x = i32;</code> …");
236236
t("type `Type<'static>` ...", "type <code>Type<'static></code> …");
237237
t("# top header", "top header");
238+
t("# top header\n\nfollowed by a paragraph", "top header");
238239
t("## header", "header");
239240
t("first paragraph\n\nsecond paragraph", "first paragraph");
240241
t("```\nfn main() {}\n```", "");

0 commit comments

Comments
 (0)