mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-11 21:02:45 +00:00
Skip RTF header/footer left, right and first-page groups on import
Found while testing crates/textimport/src/rtf.rs:43-63 (SKIP list) and :201 (`SKIP.contains(&word.as_str())`) 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:
1 parent
a337204cfe
commit
55729a5128
1 file changed
+15
@@ -47,7 +47,13 @@ const SKIP: &[&str] = &[
|
||||
"info",
|
||||
"pict",
|
||||
"header",
|
||||
"headerl",
|
||||
"headerr",
|
||||
"headerf",
|
||||
"footer",
|
||||
"footerl",
|
||||
"footerr",
|
||||
"footerf",
|
||||
"footnote",
|
||||
"listtable",
|
||||
"listoverridetable",
|
||||
@@ -310,6 +316,15 @@ fn cp1252(b: u8) -> char {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn header_and_footer_variants_are_skipped() {
|
||||
for w in ["header", "headerl", "headerr", "headerf", "footer", "footerl", "footerr", "footerf"] {
|
||||
let rtf = format!(r"{{\rtf1\ansi {{\{w} Page head\par}}Body text\par}}");
|
||||
let text = import(rtf.as_bytes()).unwrap().story.text;
|
||||
assert_eq!(text.trim_end(), "Body text", "{w}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn out_of_range_unicode_escape_is_dropped() {
|
||||
assert_eq!(import(br"{\rtf1 a\u4294967361?b}").unwrap().story.text, "ab");
|
||||
|
||||
Reference in new issue
Block a user