Cut off plain text descriptions after headers

Before:

    The Rust Standard LibraryThe Rust Standard Library is the foundation of portable Rust software, a set of minimal and battle-tested shared abstractions for the broader Rust ecosystem. It offers core types, like `Vec<T>` and `Option<T>`, library-defined operations on language primitives, standard macros, I/O and multithreading, among many other things.

After:

    The Rust Standard Library
This commit is contained in:
Michael Howell
2021-02-20 16:45:56 -07:00
parent 553852806d
commit 1bedd4d678
2 changed files with 2 additions and 0 deletions
+1
View File
@@ -1124,6 +1124,7 @@ fn push(s: &mut String, text_length: &mut usize, text: &str) {
Event::HardBreak | Event::SoftBreak => s.push(' '),
Event::Start(Tag::CodeBlock(..)) => break,
Event::End(Tag::Paragraph) => break,
Event::End(Tag::Heading(..)) => break,
_ => (),
}
}
+1
View File
@@ -230,6 +230,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 some text", "top header");
t("## header", "header");
t("first paragraph\n\nsecond paragraph", "first paragraph");
t("```\nfn main() {}\n```", "");