fix: check correctly for new lines when filtering html

This commit is contained in:
2022-02-08 14:52:50 +01:00
parent ac3c59323b
commit 0100c7e453

View File

@@ -1413,6 +1413,7 @@ void HTMLParser::ReadTextUntilClosingTag(bool put_closing_tag_as_well)
// reading text between html tags // reading text between html tags
void HTMLParser::ReadText(bool is_cdata) void HTMLParser::ReadText(bool is_cdata)
{ {
new_item_has_new_line_before = false;
bool was_white_char = false; bool was_white_char = false;
bool was_new_line = false; bool was_new_line = false;
@@ -1448,6 +1449,9 @@ void HTMLParser::ReadText(bool is_cdata)
tmp_text.clear(); tmp_text.clear();
was_closing_tag = PutNormalNonWhite(tmp_text, allow_put_new_line, allow_put_space, is_cdata); 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() ) if( !tmp_text.empty() )
{ {
allow_put_new_line = false; allow_put_new_line = false;
@@ -1464,6 +1468,7 @@ void HTMLParser::ReadText(bool is_cdata)
{ {
SkipWhiteLines(text_space_wstr); SkipWhiteLines(text_space_wstr);
PutNonBreakingSpace(); PutNonBreakingSpace();
was_new_line = false;
} }
} }
else else
@@ -1502,7 +1507,6 @@ void HTMLParser::ReadText(bool is_cdata)
} }
text_space_tmp.clear(); text_space_tmp.clear();
new_item_has_new_line_before = was_new_line;
} }