From b1c3b9d768b6c3136c40cfc1c5f82a3ed4bceeac Mon Sep 17 00:00:00 2001 From: jpirnay Date: Mon, 30 Mar 2026 13:35:11 +0200 Subject: [PATCH] Fix unwanted br alignment reset --- lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp index 705a6f7a..63e66452 100644 --- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp +++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp @@ -1104,11 +1104,15 @@ void XMLCALL ChapterHtmlSlimParser::endElement(void* userData, const XML_Char* n // Margins/padding are preserved so parent element spacing still accumulates correctly. if (self->currentTextBlock && self->currentTextBlock->isEmpty()) { auto style = self->currentTextBlock->getBlockStyle(); - style.textAlignDefined = false; - style.alignment = (self->paragraphAlignment == static_cast(CssTextAlign::None)) - ? CssTextAlign::Justify - : static_cast(self->paragraphAlignment); - self->currentTextBlock->setBlockStyle(style); + // Keep alignment for synthetic empty
separator blocks so following inline + // text after
inside centered/right-aligned containers preserves alignment. + if (!style.fromBrElement) { + style.textAlignDefined = false; + style.alignment = (self->paragraphAlignment == static_cast(CssTextAlign::None)) + ? CssTextAlign::Justify + : static_cast(self->paragraphAlignment); + self->currentTextBlock->setBlockStyle(style); + } } } }