Add support for horizontal rulers

This commit is contained in:
jpirnay
2026-05-15 11:12:56 +02:00
parent 501d9a4d19
commit 4a5c2a4ed5
9 changed files with 80 additions and 1 deletions
@@ -1049,6 +1049,26 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
self->preUntilDepth = std::min(self->preUntilDepth, self->depth);
}
}
} else if (strcmp(name, "hr") == 0) {
if (self->partWordBufferIndex > 0) self->flushPartWordBuffer();
self->makePages();
if (!self->currentPage) {
self->currentPage.reset(new Page());
self->currentPageNextY = 0;
}
const int lineHeight = self->renderer.getLineHeight(self->fontId) * self->lineCompression;
const int16_t marginV = static_cast<int16_t>(lineHeight / 2);
self->currentPageNextY += marginV;
if (self->currentPageNextY + 1 + marginV > self->viewportHeight) {
self->emitPage(self->lastBodyChildByteOffset);
self->currentPage.reset(new Page());
self->currentPageNextY = 0;
}
self->currentPage->elements.push_back(
std::make_shared<PageHR>(0, self->currentPageNextY, static_cast<int16_t>(self->viewportWidth)));
self->currentPageNextY += 1 + marginV;
BlockStyle emptyStyle;
self->startNewTextBlock(emptyStyle);
} else if (matches(name, UNDERLINE_TAGS, NUM_UNDERLINE_TAGS) ||
matches(name, STRIKETHROUGH_TAGS, NUM_STRIKETHROUGH_TAGS)) {
// Flush buffer before style change so preceding text gets current style