1
Fork 0

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

View file

@ -1124,6 +1124,7 @@ crate fn plain_text_summary(md: &str) -> String {
Event::HardBreak | Event::SoftBreak => s.push(' '),
Event::Start(Tag::CodeBlock(..)) => break,
Event::End(Tag::Paragraph) => break,
Event::End(Tag::Heading(..)) => break,
_ => (),
}
}

View file

@ -230,6 +230,7 @@ fn test_plain_text_summary() {
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```", "");