From 1525dae1bd1c2b660edc7320dcfa9da6d0b2143d Mon Sep 17 00:00:00 2001 From: Marco Arnulfo Date: Sat, 24 Oct 2026 19:08:05 +0200 Subject: [PATCH] Files: opening an RTF outline keeps non-breaking hyphens --- crates/format/src/rtf.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/format/src/rtf.rs b/crates/format/src/rtf.rs index 5c7cf106..c9a6a019 100644 --- a/crates/format/src/rtf.rs +++ b/crates/format/src/rtf.rs @@ -239,6 +239,7 @@ pub fn rtf_to_outline(rtf: &str) -> String { match n { b'\\' | b'{' | b'}' => line.push(n as char), b'~' => line.push('\u{a0}'), + b'_' => line.push('\u{2011}'), b'\n' | b'\r' => flush(&mut line, level, indent, &mut out), _ => {} } @@ -337,6 +338,12 @@ mod tests { assert_eq!(rtf_to_outline(r"{\rtf1 x\u-70000?y\par}"), "x\u{ee90}y\n"); } + /// `\\_` is RTF's non-breaking hyphen: a visible character, not markup. + #[test] + fn non_breaking_hyphen_is_kept() { + assert_eq!(rtf_to_outline(r"{\rtf1\pard Year\_end review\par}"), "Year\u{2011}end review\n"); + } + /// A hostile `\li` near `i64::MAX` overflowed the rounding addend in debug builds. #[test] fn huge_left_indent_gives_the_deepest_level() {