Keep insertions from multiple classes within the page height
This commit is contained in:
1 parent
c3277531d3
commit
12d8ae805b
2 files changed
+39
-1
No files matched your search
@@ -914,6 +914,14 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
VerticalItem::Insertion(insertion) => {
|
||||
let capacity = document.page_goal.saturating_sub(document.top_skip).max(1);
|
||||
if insertion_height + insertion.height > capacity
|
||||
&& (!current.items.is_empty() || !current.insertions.is_empty())
|
||||
{
|
||||
pages.push(std::mem::replace(&mut current, Page::empty()));
|
||||
used = document.top_skip;
|
||||
insertion_height = 0;
|
||||
}
|
||||
let class_limit = document
|
||||
.insertion_class_limit(insertion.class)
|
||||
.min(document.page_goal.saturating_sub(document.top_skip))
|
||||
@@ -1665,6 +1673,36 @@ mod tests {
|
||||
assert_eq!(layout.pages()[1].insertions.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insertions_from_multiple_classes_respect_the_page_height() {
|
||||
let rule = VerticalItem::Rule {
|
||||
width: 65_536,
|
||||
height: 60,
|
||||
};
|
||||
let mut document = Document::new(
|
||||
100,
|
||||
vec![
|
||||
Unit::insertion(1, 1, 60, vec![rule.clone()]),
|
||||
Unit::insertion(2, 2, 60, vec![rule]),
|
||||
],
|
||||
);
|
||||
document.top_skip = 0;
|
||||
document.insertion_classes = vec![
|
||||
InsertionClass {
|
||||
number: 1,
|
||||
fraction_percent: 60,
|
||||
},
|
||||
InsertionClass {
|
||||
number: 2,
|
||||
fraction_percent: 60,
|
||||
},
|
||||
];
|
||||
let layout = Engine::layout(&document);
|
||||
assert_eq!(layout.pages().len(), 2);
|
||||
assert_eq!(layout.pages()[0].insertions.len(), 1);
|
||||
assert_eq!(layout.pages()[1].insertions.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_large_top_float_gets_a_float_page() {
|
||||
let mut document = Document::new(100, Vec::new());
|
||||
|
||||
+1
-1
@@ -267,7 +267,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 149 unit tests plus two route-D integration tests. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 246 tests (149 route-D unit, 2 route-D integration, 71 v1 integration, 19 server, 4 v1 unit, 1 doctest). v1 remains the live server path.
|
||||
The crate currently has 150 unit tests plus two route-D integration tests. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 248 tests (150 route-D unit, 2 route-D integration, 71 v1 integration, 19 server, 4 v1 unit, 1 core unit, 1 doctest). v1 remains the live server path.
|
||||
|
||||
### M0 incremental demo
|
||||
|
||||
|
||||
Reference in new issue
Block a user