diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp
index 1d7e2ab3..16af6245 100644
--- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp
+++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp
@@ -125,6 +125,20 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
self->boldUntilDepth = std::min(self->boldUntilDepth, self->depth);
} else if (matches(name, BLOCK_TAGS, NUM_BLOCK_TAGS)) {
if (strcmp(name, "br") == 0) {
+ // flush word preceding
to currentTextBlock before calling startNewTextBlock
+ EpdFontFamily::Style fontStyle = EpdFontFamily::REGULAR;
+ if (self->boldUntilDepth < self->depth && self->italicUntilDepth < self->depth) {
+ fontStyle = EpdFontFamily::BOLD_ITALIC;
+ } else if (self->boldUntilDepth < self->depth) {
+ fontStyle = EpdFontFamily::BOLD;
+ } else if (self->italicUntilDepth < self->depth) {
+ fontStyle = EpdFontFamily::ITALIC;
+ }
+
+ self->partWordBuffer[self->partWordBufferIndex] = '\0';
+ self->currentTextBlock->addWord(self->partWordBuffer, fontStyle);
+ self->partWordBufferIndex = 0;
+
self->startNewTextBlock(self->currentTextBlock->getStyle());
} else {
self->startNewTextBlock((TextBlock::Style)self->paragraphAlignment);