Stack insertion classes from the page bottom
This commit is contained in:
1 parent
060405fca6
commit
6a7e79fa03
3 files changed
+69
-14
No files matched your search
@@ -1799,6 +1799,50 @@ mod tests {
|
||||
assert!(y > 690 * 65_536);
|
||||
assert!(y < 700 * 65_536);
|
||||
}
|
||||
#[test]
|
||||
fn insertion_classes_stack_from_the_page_bottom() {
|
||||
let page = Page {
|
||||
items: vec![
|
||||
VerticalItem::Insertion(Insertion {
|
||||
class: 1,
|
||||
height: 10 * 65_536,
|
||||
items: vec![VerticalItem::Rule {
|
||||
width: 10 * 65_536,
|
||||
height: 10 * 65_536,
|
||||
}],
|
||||
}),
|
||||
VerticalItem::Insertion(Insertion {
|
||||
class: 0,
|
||||
height: 10 * 65_536,
|
||||
items: vec![VerticalItem::Rule {
|
||||
width: 10 * 65_536,
|
||||
height: 10 * 65_536,
|
||||
}],
|
||||
}),
|
||||
],
|
||||
insertions: Vec::new(),
|
||||
marks: Vec::new(),
|
||||
floats: Vec::new(),
|
||||
sources: Vec::new(),
|
||||
hash: 0,
|
||||
};
|
||||
let list = page.display_list_with_goal(100 * 65_536);
|
||||
let mut rules: Vec<i64> = list
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|item| match item {
|
||||
crate::render::DisplayItem::Rule { y, width, .. } if *width == 10 * 65_536 => {
|
||||
Some(*y)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
rules.sort_unstable();
|
||||
assert_eq!(rules.len(), 2);
|
||||
assert_eq!(rules[0], 78 * 65_536);
|
||||
assert_eq!(rules[1], 90 * 65_536);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insertion_material_sits_at_the_page_bottom() {
|
||||
let page = Page {
|
||||
|
||||
@@ -335,14 +335,6 @@ impl Page {
|
||||
.filter(|item| !matches!(item, VerticalItem::Insertion(_)))
|
||||
.cloned()
|
||||
.collect();
|
||||
let insertion_items: Vec<VerticalItem> = self
|
||||
.items
|
||||
.iter()
|
||||
.flat_map(|item| match item {
|
||||
VerticalItem::Insertion(insertion) => insertion.items.clone(),
|
||||
_ => Vec::new(),
|
||||
})
|
||||
.collect();
|
||||
for item in &items {
|
||||
match item {
|
||||
VerticalItem::Box(box_) => {
|
||||
@@ -416,9 +408,27 @@ impl Page {
|
||||
}
|
||||
}
|
||||
}
|
||||
if !insertion_items.is_empty() {
|
||||
let mut class_groups: Vec<(u8, Vec<VerticalItem>)> = Vec::new();
|
||||
let inline_insertions = self.items.iter().filter_map(|item| match item {
|
||||
VerticalItem::Insertion(insertion) => Some(insertion),
|
||||
_ => None,
|
||||
});
|
||||
for insertion in inline_insertions.chain(self.insertions.iter()) {
|
||||
if let Some((_, items)) = class_groups
|
||||
.iter_mut()
|
||||
.find(|(class, _)| *class == insertion.class)
|
||||
{
|
||||
items.extend(insertion.items.iter().cloned());
|
||||
} else {
|
||||
class_groups.push((insertion.class, insertion.items.clone()));
|
||||
}
|
||||
}
|
||||
class_groups.sort_by_key(|(class, _)| *class);
|
||||
let body_bottom = y;
|
||||
let mut insertion_bottom = page_goal;
|
||||
for (class, items) in class_groups {
|
||||
let insertion_page = Page {
|
||||
items: insertion_items,
|
||||
items,
|
||||
insertions: Vec::new(),
|
||||
marks: Vec::new(),
|
||||
floats: Vec::new(),
|
||||
@@ -427,13 +437,13 @@ impl Page {
|
||||
};
|
||||
let mut insertion_list = insertion_page.display_list();
|
||||
let top = if page_goal > 0 {
|
||||
(page_goal - insertion_list.height).max(y)
|
||||
(insertion_bottom - insertion_list.height).max(body_bottom)
|
||||
} else {
|
||||
y
|
||||
};
|
||||
insertion_list.place(0, top);
|
||||
let width = insertion_list.width.max(list.width);
|
||||
if page_goal > 0 && top > y + 26_214 {
|
||||
if class == 0 && page_goal > 0 && top > body_bottom + 26_214 {
|
||||
let separator_width = (body_width * 2 / 5).max(65_536);
|
||||
list.push(DisplayItem::Rule {
|
||||
x: 0,
|
||||
@@ -446,6 +456,7 @@ impl Page {
|
||||
list.items.extend(insertion_list.items);
|
||||
list.images.extend(insertion_list.images);
|
||||
list.width = list.width.max(width);
|
||||
insertion_bottom = top.saturating_sub(131_072);
|
||||
}
|
||||
if page_goal > 0 {
|
||||
let bottom_height: i64 = self
|
||||
|
||||
+2
-2
@@ -262,7 +262,7 @@ M3 (partial): `Unit::halign` normalizes column widths, intercolumn gaps, row hei
|
||||
|
||||
Math coverage includes fractions/roots, scripts, `\left...\right` with body-scaled delimiters, `\middle`, `\big`/`\Big`/`\bigg`/`\Bigg` and their `l`/`r` forms, control-sequence delimiters, accents (dot/check/breve/acute/grave/ring), `\text`/`\mathrm`, `\overbrace`/`\underbrace`, `\overset`/`\underset`, `\binom`, `\cancel`/`\bcancel`/`\xcancel`, `\bmod`/`\pmod`, fence symbols, `\operatorname*` and `\mathop` limits.
|
||||
|
||||
The crate currently has 133 unit tests plus one route-D integration test. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 216 tests (133 route-D unit, 1 route-D integration, 71 v1 integration, 6 server, 4 v1 unit, 1 doctest). v1 remains the live server path.
|
||||
The crate currently has 134 unit tests plus one route-D integration test. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 217 tests (134 route-D unit, 1 route-D integration, 71 v1 integration, 6 server, 4 v1 unit, 1 doctest). v1 remains the live server path.
|
||||
|
||||
### M0 incremental demo
|
||||
|
||||
@@ -291,7 +291,7 @@ deliberately open rather than approximated:
|
||||
pdfTeX line breaks and full hyphenation demerits are not reproduced generally.
|
||||
- **M5**: `cmr10.tfm` is parsed at runtime with widths, glyph heights/depths and kern pairs. all five text faces embed Liberation Serif/Mono as Type0/Identity-H with `/W` widths; ff/fi/fl/ffi/ffl ligatures come from TFM, and CMR10 italic corrections are applied at line ends; full NFSS family switching is not implemented.
|
||||
- **M6**: `\output`, `\insert`, mark/float output policies, class-file execution and
|
||||
math limit policies are only partially modeled; `OutputRoutine::wants_break` can force a page break between units, but `\output` is still Rust code rather than interpreted tokens.
|
||||
math limit policies are only partially modeled; `OutputRoutine::wants_break` can force a page break between units, and insertion material is stacked by class from the page bottom; `\output` is still Rust code rather than interpreted tokens.
|
||||
- **M7**: `POST /api/route-d/preview` and `/api/route-d/edit/{unit}` expose
|
||||
route-D pages and edit diff; the preview path lays out
|
||||
blank-line-separated plain text and returns route-D pages with SVG and page
|
||||
|
||||
Reference in new issue
Block a user