jneug / typst-codelst

A typst package to render sourcecode
MIT License
87 stars 5 forks source link

Edge case: Sometimes broken PDF output when spanning multiple pages #9

Open qrnch-jan opened 10 months ago

qrnch-jan commented 10 months ago

I think I've found a strange edge case. This appears to happen when a code listing spans over a page break, but the code listing on the second page is just a few lines. This is what the PDF output turns into:

1 Blah on line 1
2 Blah again on line 2
3 More blah, line 3
4
--PAGE BREAK--
5 Even more blah, line 4
   Final line 5

The line number remains on the first page, but the line's contents are pushed to the next page, shifting the final line onto a line with no line number. The problem appears to disappear if the second page contains more lines of code.

To be honest, this is not a problem in practice because I try to avoid page breaks in listings like the plague. And even in cases where I do have page breaks in a listing, for stylistic reasons I wouldn't allow just one or two trailing lines on the second page. With that said, it looks like a bug so I'm reporting it.

Using codelst 1.0.0. Reproducible on typst 0.9.0 and 0.10.0 on macOS.