ggrossetie / asciidoctor-web-pdf

Convert AsciiDoc documents to PDF using web technologies
https://asciidoctor.org
MIT License
455 stars 92 forks source link

Math lines at the end of a page: breaks Page.checkUnderflowAfterResize #662

Open jhannwong opened 2 years ago

jhannwong commented 2 years ago
An uncaught exception happened within the HTML page: Error: TypeError: Cannot read properties of undefined (reading 'ref')
    at validNode (file:///.../test.html:3388:39)
    at Layout.findEndToken (file:///.../test.html:4205:17)
    at Page.checkUnderflowAfterResize (file:///.../test.html:4587:37)
    at file:///.../test.html:4559:13

The AsciiDoc just needs to happen to have a math line at the end of a page. Try this:

= Some Document
:stem: latexmath

== Just 1 chapter

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

stem:[\displaystyle \frac{1}{2}]

// A line of text here will help the next math line go to the next page.

stem:[\displaystyle \frac{1}{2}]

== Next chapter

Some text.
ggrossetie commented 2 years ago

I cannot reproduce this issue on the main branch. Here's the PDF produced: test.pdf

jhannwong commented 2 years ago

Your test.pdf has enough math lines to just about fill up the 1st page. Try adding more so that they overflow to the 2nd page?

ggrossetie commented 2 years ago

It also works test.pdf Do you use a custom style? Could you please try with the latest version?