mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-29 04:56:58 -06:00
fix: decode to a non-breaking space so blank paragraphs survive trimming
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
e54bd2ccb7
commit
03993057a4
@@ -313,7 +313,7 @@ fn decode_text(raw: &str) -> String {
|
||||
"gt" => Some('>'),
|
||||
"quot" => Some('"'),
|
||||
"apos" => Some('\''),
|
||||
"nbsp" => Some(' '),
|
||||
"nbsp" => Some('\u{a0}'),
|
||||
_ => entity.strip_prefix('#').and_then(numeric_char),
|
||||
};
|
||||
if let Some(c) = decoded {
|
||||
|
||||
@@ -268,6 +268,30 @@ fn html_paste_with_a_source_newline_keeps_its_bold() {
|
||||
assert_eq!(body.paragraphs[0].runs[0].props.bold, Some(true), "{body:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn html_paste_keeps_a_blank_nbsp_paragraph_and_the_rich_path() {
|
||||
for blank in ["<p> </p>", "<p><o:p> </o:p></p>"] {
|
||||
let mut s = session();
|
||||
let html = format!("<p><b>A</b></p>{blank}<p>B</p>");
|
||||
s.execute("edit.paste", &json!({"text": "A\n\u{a0}\nB", "html": html})).unwrap();
|
||||
let body = s
|
||||
.doc()
|
||||
.unwrap()
|
||||
.current_slide()
|
||||
.unwrap()
|
||||
.shapes
|
||||
.iter()
|
||||
.find(|sh| sh.text.as_ref().is_some_and(|t| t.paragraphs.len() == 3))
|
||||
.unwrap()
|
||||
.text
|
||||
.clone()
|
||||
.unwrap();
|
||||
assert_eq!(body.paragraphs[0].runs[0].text, "A", "{html}: {body:?}");
|
||||
assert_eq!(body.paragraphs[0].runs[0].props.bold, Some(true), "{html}: {body:?}");
|
||||
assert_eq!(body.paragraphs[2].runs[0].text, "B", "{html}: {body:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_ungroup_roundtrip_positions() {
|
||||
let mut s = session();
|
||||
|
||||
Reference in New Issue
Block a user