mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-16 23:42:27 +00:00
rtf: keep direction words in old paragraph formatting
\rtlpar, \ltrpar, \rtldir and \ltrdir are paragraph formatting words, so \oldpprops holds them and a tracked direction change keeps the old direction. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
376fa26e4c
commit
d869560911
2 files changed
+18
No files matched your search
@@ -208,6 +208,10 @@ pub(super) fn is_format_word(w: &str) -> bool {
|
||||
| "s"
|
||||
| "outlinelevel"
|
||||
| "pagebb"
|
||||
| "rtlpar"
|
||||
| "ltrpar"
|
||||
| "rtldir"
|
||||
| "ltrdir"
|
||||
| "intbl"
|
||||
| "ls"
|
||||
| "ilvl"
|
||||
|
||||
@@ -80,6 +80,20 @@ fn rtl_paragraph_styles_carry_their_direction() {
|
||||
assert_eq!(rtl, [true, true, false, false, true, false]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oldpprops_keep_the_old_paragraph_direction() {
|
||||
// A tracked change of direction: now LTR, before RTL (`\rtlpar` in the old properties).
|
||||
let rtf = br"{\rtf1\ansi{\*\revtbl {Unknown;}{Alice;}}
|
||||
\pard\ltrpar\prauth1\prdate-2014675576{\*\oldpprops \pard \rtlpar}A\par}";
|
||||
let flow = parse(rtf).unwrap();
|
||||
let Some(FBlock::Para(p)) = flow.blocks.first() else { panic!("no paragraph") };
|
||||
assert!(!p.rtl);
|
||||
assert!(p.fmt_change.as_deref().expect("paragraph change").old.rtl, "old direction is RTL");
|
||||
let doc = import(rtf).unwrap();
|
||||
let c = doc_paras(&doc)[0].props.fmt_change.as_deref().expect("change");
|
||||
assert_eq!(c.old.bidi, Some(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stylesheet_names_take_unicode_escapes() {
|
||||
// \u116?=t \u105?=i \u116?=t \u108?=l \u101?=e — how Word writes a non-Latin style name.
|
||||
|
||||
Reference in new issue
Block a user