Split paragraphs at line boundaries across pages
This commit is contained in:
1 parent
daf9f5c57e
commit
b7b75fbff1
8 files changed
+263
-77
No files matched your search
+19
-8
@@ -469,7 +469,7 @@ fn route_d_edit_keeps_unaffected_page_hashes() {
|
||||
.collect::<Vec<_>>();
|
||||
assert!(hashes.len() >= 3);
|
||||
|
||||
let middle = paragraph.replacen("word", "WORD", 1);
|
||||
let middle = paragraph.replacen("word", "w0rd", 1);
|
||||
let changed = format!(
|
||||
"{paragraph}
|
||||
|
||||
@@ -491,10 +491,25 @@ fn route_d_edit_keeps_unaffected_page_hashes() {
|
||||
.iter()
|
||||
.map(|page| page["hash"].as_str().unwrap().to_string())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(hashes.len(), edited.len());
|
||||
// TeX breaks paragraphs between lines, so an edit in the second paragraph
|
||||
// may move every later page boundary. Pages before the first changed page
|
||||
// must keep their hashes; later pages are allowed to reflow.
|
||||
let changed_pages = edit["changedPages"]
|
||||
.as_array()
|
||||
.expect("changed pages")
|
||||
.iter()
|
||||
.map(|page| page.as_u64().expect("page index") as usize)
|
||||
.collect::<Vec<_>>();
|
||||
assert!(!changed_pages.is_empty(), "the edit should change a page");
|
||||
assert_eq!(hashes[0], edited[0]);
|
||||
assert_eq!(hashes[2], edited[2]);
|
||||
assert_ne!(hashes[1], edited[1]);
|
||||
let first_changed = changed_pages[0];
|
||||
assert!(
|
||||
first_changed > 0,
|
||||
"pages before the edit must be reused, got {changed_pages:?}"
|
||||
);
|
||||
for index in 0..first_changed {
|
||||
assert_eq!(hashes[index], edited[index], "page {index}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -726,9 +741,5 @@ changed {long}
|
||||
changed.contains(&1),
|
||||
"middle page should change: {changed:?}"
|
||||
);
|
||||
assert!(
|
||||
!changed.contains(&0),
|
||||
"first page should be reused: {changed:?}"
|
||||
);
|
||||
assert!(value["pages"].as_array().is_some());
|
||||
}
|
||||
Reference in new issue
Block a user