From 0100c7e453b1b140ec5b31c726d65de25812d620 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Tue, 8 Feb 2022 14:52:50 +0100 Subject: [PATCH] fix: check correctly for new lines when filtering html --- src/html/htmlparser.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; }