Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,11 +1059,14 @@ fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool)

'outer: for event in Parser::new_ext(md, Options::ENABLE_STRIKETHROUGH) {
match &event {
// Note: update this if more text (not style) nodes are added.
// This is needed so that all tags are closed before we stop.
Event::Text(_) | Event::Code(_) if stopped_early => break,
Event::Text(text) => {
for word in text.split_inclusive(char::is_whitespace) {
if text_length + word.len() >= length_limit {
stopped_early = true;
break 'outer;
continue 'outer;
}

push(&mut s, &mut text_length, word);
Expand All @@ -1072,7 +1075,7 @@ fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool)
Event::Code(code) => {
if text_length + code.len() >= length_limit {
stopped_early = true;
break;
continue;
}

s.push_str("<code>");
Expand All @@ -1094,7 +1097,7 @@ fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool)
Event::HardBreak | Event::SoftBreak => {
if text_length + 1 >= length_limit {
stopped_early = true;
break;
continue;
}

push(&mut s, &mut text_length, " ");
Expand Down