fix: allow images to share first chapter page with title

Only force a page break before an image when it won't fit in the
remaining page space, instead of unconditionally breaking whenever
the page has any content.
This commit is contained in:
Martin Brook 2026-01-28 19:35:28 +00:00
parent d9c204f3a3
commit 3982f249a8

View File

@ -176,8 +176,9 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
Serial.printf("[%lu] [EHP] Display size: %dx%d (scale %.2f)\n", millis(), displayWidth, displayHeight,
scale);
// Create page for image
if (self->currentPage && !self->currentPage->elements.empty()) {
// Create page for image - only break if image won't fit remaining space
if (self->currentPage && !self->currentPage->elements.empty() &&
(self->currentPageNextY + displayHeight > self->viewportHeight)) {
self->completePageFn(std::move(self->currentPage));
self->currentPage.reset(new Page());
if (!self->currentPage) {