diff --git a/src/reader.rs b/src/reader.rs index 6a35459..c1afb5a 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -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; + } } } }