diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp index 90bf8fee..d502933d 100644 --- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp +++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp @@ -789,6 +789,20 @@ void XMLCALL ChapterHtmlSlimParser::endElement(void* userData, const XML_Char* n if (headerOrBlockTag) { self->currentCssStyle.reset(); self->updateEffectiveInlineStyle(); + + // Reset alignment on empty text blocks to prevent stale alignment from bleeding + // into the next sibling element. This fixes issue #1026 where an empty
causes Center to persist through the chain
+ // of empty block reuse into subsequent text paragraphs.
+ // 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 Navigate back to Page A - it should load faster from cache. Tests that image centering does not bleed into following text blocks (issue #1026). Set Paragraph Alignment to Justify and Embedded Style to OFF before testing. All paragraphs below the images should be justified, not centered. FIRST PARAGRAPH after image. This paragraph follows an empty heading and an image-only paragraph. With the bug present, this text appears centered instead of justified because the empty heading's default Center alignment bleeds through the chain of empty text blocks. Lorem ipsum dolor sit amet, consectetur adipiscing elit sed do eiusmod tempor. SECOND PARAGRAPH in the same div. This paragraph should always be justified because the first paragraph's text block was flushed. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia. Navigate back to Page A - it should load faster from cache. Tests that image centering does not bleed into following text blocks (issue #1026). Set Paragraph Alignment to Justify and Embedded Style to OFF before testing. All paragraphs below the images should be justified, not centered. FIRST PARAGRAPH after image. This paragraph follows an empty heading and an image-only paragraph. With the bug present, this text appears centered instead of justified because the empty heading's default Center alignment bleeds through the chain of empty text blocks. Lorem ipsum dolor sit amet, consectetur adipiscing elit sed do eiusmod tempor. SECOND PARAGRAPH in the same div. This paragraph should always be justified because the first paragraph's text block was flushed. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia.

