diff --git a/src/html/htmlparser.cpp b/src/html/htmlparser.cpp
index 4186445..57f8d00 100644
--- a/src/html/htmlparser.cpp
+++ b/src/html/htmlparser.cpp
@@ -1413,6 +1413,7 @@ void HTMLParser::ReadTextUntilClosingTag(bool put_closing_tag_as_well)
// reading text between html tags
void HTMLParser::ReadText(bool is_cdata)
{
+ new_item_has_new_line_before = false;
bool was_white_char = false;
bool was_new_line = false;
@@ -1448,6 +1449,9 @@ void HTMLParser::ReadText(bool is_cdata)
tmp_text.clear();
was_closing_tag = PutNormalNonWhite(tmp_text, allow_put_new_line, allow_put_space, is_cdata);
+ if( lastc == -1 || was_closing_tag )
+ new_item_has_new_line_before = was_new_line;
+
if( !tmp_text.empty() )
{
allow_put_new_line = false;
@@ -1464,6 +1468,7 @@ void HTMLParser::ReadText(bool is_cdata)
{
SkipWhiteLines(text_space_wstr);
PutNonBreakingSpace();
+ was_new_line = false;
}
}
else
@@ -1502,7 +1507,6 @@ void HTMLParser::ReadText(bool is_cdata)
}
text_space_tmp.clear();
- new_item_has_new_line_before = was_new_line;
}