fix(reader): skip leading newlines after page split to prevent blank top/bottom
This commit is contained in:
@@ -438,11 +438,17 @@ pub fn calculate_pages(text: &str, chars_per_line: usize, lines_per_page: usize)
|
||||
split = i;
|
||||
}
|
||||
if split < total {
|
||||
pages.push(split);
|
||||
page_start = split;
|
||||
line_count = 0;
|
||||
line_pos = 0;
|
||||
i = split;
|
||||
// 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;
|
||||
line_count = 0;
|
||||
line_pos = 0;
|
||||
i = split;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user