diff --git a/crates/engine/src/cmd/richclip.rs b/crates/engine/src/cmd/richclip.rs index e813e743..db7feb56 100644 --- a/crates/engine/src/cmd/richclip.rs +++ b/crates/engine/src/cmd/richclip.rs @@ -126,6 +126,9 @@ pub fn html_to_body(html: &str) -> Option { } continue; } + if is_block(&name) { + new_para(&mut paragraphs); + } if is_break(&name) { new_para(&mut paragraphs); continue; @@ -394,6 +397,15 @@ mod tests { } } + #[test] + fn text_before_opening_block_tag_is_separate_paragraph() { + for tag in ["div", "p", "li", "h1"] { + let body = html_to_body(&format!("Hello<{tag}>world")).unwrap(); + let texts: Vec = body.paragraphs.iter().map(|p| p.runs.iter().map(|r| r.text.as_str()).collect()).collect(); + assert_eq!(texts, ["Hello", "world"], "{tag}"); + } + } + #[test] fn multibyte_after_ampersand_is_kept() { let text = "é".repeat(20);