Merge pull request #2098 from Silvertree2010/fix/h5002-text-only-and-rtf-story-export-w

Drop text variable markers in Text Only and RTF story export
This commit is contained in:
Brandon Thomas
2026-11-01 14:48:51 -05:00
committed by GitHub
+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");