Treat header as first paragraph for shortened markdown descriptions

"The Rust Standard LibraryThe Rust Standard Library is the …" is an awful description.
This commit is contained in:
Michael Howell 2021-03-09 17:48:14 -07:00
parent 3a5d45f68c
commit e40b3d6a38
2 changed files with 2 additions and 0 deletions

View File

@ -1093,6 +1093,7 @@ fn push(s: &mut String, text_length: &mut usize, text: &str) {
Tag::Emphasis => s.push_str("</em>"),
Tag::Strong => s.push_str("</strong>"),
Tag::Paragraph => break,
Tag::Heading(..) => break,
_ => {}
},
Event::HardBreak | Event::SoftBreak => {

View File

@ -235,6 +235,7 @@ fn t(input: &str, expect: &str) {
t("code `let x = i32;` ...", "code <code>let x = i32;</code> …");
t("type `Type<'static>` ...", "type <code>Type<'static></code> …");
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```", "");