mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-01 22:26:49 -06:00
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:
co-authored by
Claude Haiku 5.5
parent
ea214dd44d
commit
00717534cb
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user