Drop text variable markers in Text Only and RTF story export

Found while testing crates/textimport/src/export.rs:18 (plain_char) and :177 (rtf)

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:
NetterSilver
2026-10-31 20:55:44 +01:00
co-authored by Claude Haiku 5.5
parent ea214dd44d
commit 00717534cb
+10 -2
View File
@@ -15,7 +15,7 @@ fn plain_char(c: char) -> Option<&'static str> {
match c {
PAGE_NUMBER | NEXT_PAGE_NUMBER | PREV_PAGE_NUMBER => Some("#"),
FORCED_LINE_BREAK => Some("\u{2028}"),
'\u{E000}'..='\u{E0FF}' => None,
'\u{E000}'..='\u{E1FF}' => None,
_ => Some(""),
}
}
@@ -174,7 +174,7 @@ pub fn rtf(doc: &Document, story: &Story) -> String {
}
}
PAGE_NUMBER | NEXT_PAGE_NUMBER | PREV_PAGE_NUMBER => out.push('#'),
'\u{E000}'..='\u{E0FF}' => {}
'\u{E000}'..='\u{E1FF}' => {}
c => rtf_escape(&mut out, c),
}
}
@@ -201,6 +201,14 @@ mod tests {
st
}
#[test]
fn text_variable_markers_are_dropped() {
let st = Story::with_text(StoryId(1), "Page \u{E100} of", Default::default());
assert_eq!(plain_text(&st), "Page of");
let r = rtf(&Document::new(&NewDocument::default()), &st);
assert!(!r.contains("\\u-7936") && r.contains("Page of"), "{r}");
}
#[test]
fn text_only() {
assert_eq!(plain_text(&story()), "Plain bold {x}\r\nCafé\ntwo");