fix(reader): skip leading newlines after page split to prevent blank top/bottom
This commit is contained in:
@@ -437,6 +437,11 @@ pub fn calculate_pages(text: &str, chars_per_line: usize, lines_per_page: usize)
|
||||
if split <= page_start {
|
||||
split = i;
|
||||
}
|
||||
if split < total {
|
||||
// Skip leading newlines to prevent starting page with blank line
|
||||
while split < total && chars[split] == '\n' {
|
||||
split += 1;
|
||||
}
|
||||
if split < total {
|
||||
pages.push(split);
|
||||
page_start = split;
|
||||
@@ -446,6 +451,7 @@ pub fn calculate_pages(text: &str, chars_per_line: usize, lines_per_page: usize)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if *pages.last().unwrap() < total {
|
||||
pages.push(total);
|
||||
|
||||
Reference in New Issue
Block a user