World's first open-source enterprise world model.
Rust agent-memorybitemporalgraphragknowledge-baseknowledge-graphllmontologypgvectorpostgresqlragrustself-hostedsemantic-searchtemporal-knowledge-graphworld-model
A non-breaking hyphen in a Word document is read as a hyphen, so the numbers on either side of it stay apart (#1031)
Maya Kid6b0a1d7e7f6a
diff --git a/crates/utopia-ingest/src/parsers.rs b/crates/utopia-ingest/src/parsers.rsindex d9bbad1a..7e017740 100644--- a/crates/utopia-ingest/src/parsers.rs+++ b/crates/utopia-ingest/src/parsers.rs@@ -372,6 +372,13 @@ pub(crate) fn docx_xml_to_text(Some(c) => c.0.push(' '),None => out.push(' '),},+ // Word 的不断行连字符(Ctrl+Shift+-)不是 w:t 里的字,是一个元素:页面上照样画出+ // 连字符,只是不在这里折行。丢了它,2024‑01‑15 读成 20240115,010‑62345678 读成+ // 01062345678。写成普通连字符,日期和号码才认得出来+ "w:noBreakHyphen" => match cell.as_mut() {+ Some(c) => c.0.push('-'),+ None => out.push('-'),+ },_ => {}},Ok(Event::End(e)) => match e.name().as_ref() {diff --git a/crates/utopia-ingest/tests/docx_breaks.rs b/crates/utopia-ingest/tests/docx_breaks.rsindex ef6292e3..7250ba66 100644--- a/crates/utopia-ingest/tests/docx_breaks.rs+++ b/crates/utopia-ingest/tests/docx_breaks.rs@@ -57,3 +57,16 @@ fn paragraph_breaks_remain_newlines_and_formatting_runs_join() {let text = read("<w:p><w:r><w:t>first</w:t><w:tab/><w:t>line</w:t></w:r></w:p><w:p><w:r><w:t>second</w:t></w:r></w:p>");assert_eq!(text.trim(), "first line\nsecond");}++#[test]+fn a_non_breaking_hyphen_keeps_the_numbers_on_either_side_apart() {+ let nbh = "<w:noBreakHyphen/>";+ let text = read(&format!(+ r#"<w:p><w:r><w:t xml:space="preserve">合同于 2024</w:t>{nbh}<w:t>01</w:t>{nbh}<w:t xml:space="preserve">15 签订,电话 010</w:t></w:r><w:r>{nbh}</w:r><w:r><w:t>62345678。</w:t></w:r></w:p>"#+ ));+ assert_eq!(text.trim(), "合同于 2024-01-15 签订,电话 010-62345678。");+ let text = read(&table(&format!(+ "<w:t>2024</w:t>{nbh}<w:t>01</w:t>{nbh}<w:t>15</w:t>"+ )));+ assert!(text.contains("| Sample | 2024-01-15 |"), "{text}");+}