shadowhand/dompdf — pull request #1 by bfrohs (2012-09-21 17:14:35+00:00)
Title: Avoid page break bug with whitespace after blocks

When a paragraph is followed by whitespace (` `, `\n`, etc) that cannot fit onto the current page (last line of paragraph is last line that can fit on page), the paragraph preceding the whitespace would be pushed onto the next page, regardless of length. This makes sure the last child of the paragraph (last line) is selected instead.

# Steps to reproduce

1. Create a document with a several paragraphs of filler text.
2. Make sure the second-to-last paragraph's last line is the last line that can fit on the page

P1 Filler...

P2 Filler...

P3 Filler... 100% on page 1

P4 Filler... 100% on page 2

3. Add whitespace between the second-to-last paragraph's close tag and the last paragraph's open tag.

P1 Filler...

P2 Filler...

P3 Filler...

P4 Filler...

# Expected results

Second-to-last paragraph should be on first page regardless of whitespace.

# Actual results

Second-to-last paragraph is pushed to the second page with whitespace, but on first page without whitespace.