Honour club and widow penalties on paragraph lines
Route-D expanded a paragraph into one node per line without TeX's \clubpenalty/\widowpenalty, so a page break could orphan the first line or widow the last. Insert the penalties between line nodes (150 by default, read from the source registers) and make the page builder reject any penalty of 10000 or more as a breakpoint. Forced -10000 values now break exactly where pdfLaTeX does; two page oracle fixtures compare per-page text, and unit tests cover the node order and the forbidden breakpoint.
This commit is contained in:
1 parent
1bb28cf141
commit
8ac2e828df
6 files changed
+210
-4
No files matched your search
@@ -587,7 +587,9 @@ impl PageBuilder {
|
||||
deferred_floats.clone(),
|
||||
));
|
||||
}
|
||||
if index > start {
|
||||
// TeX treats a penalty of 10000 or more as no break at
|
||||
// all; only the forced (<= -10000) case above is stronger.
|
||||
if index > start && *penalty < 10_000 {
|
||||
candidates.push(self.candidate(
|
||||
height,
|
||||
depth,
|
||||
@@ -928,6 +930,14 @@ mod tests {
|
||||
assert_eq!(pages[1].penalty, 10_000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infinite_penalty_forbids_the_break() {
|
||||
let builder = PageBuilder::new(100);
|
||||
let nodes = vec![box_(60, 0), VerticalNode::Penalty(10_000), box_(60, 0)];
|
||||
let pages = builder.build(&nodes);
|
||||
assert_eq!(pages.len(), 1, "a 10000 penalty must not be a breakpoint");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glue_breaks_report_a_ten_thousand_penalty() {
|
||||
let builder = PageBuilder::new(100);
|
||||
|
||||
Reference in new issue
Block a user