From c0ecfc08e3bfb8d93136a859808bf713c56b68e3 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 10 Apr 2017 11:05:51 +0200 Subject: QTextDocument: improve import of DIV tags
1
2 was inserting two newlines between 1 and 2, while all tested web browsers only insert one newline - as long as there is nothing between the
and the . This was the cause for extra newlines being inserted in KMail when replying to HTML emails, such as those generated by gmail. Change-Id: I5145d977701e68913264357bba22780e7cdd3f7d Reviewed-by: Simon Hausmann --- src/gui/text/qtextdocumentfragment.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index 3a78296c57..ea37695f4e 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -825,9 +825,13 @@ bool QTextHtmlImporter::closeTag() break; case Html_div: - if (closedNode->children.isEmpty()) - break; - Q_FALLTHROUGH(); + if (cursor.position() > 0) { + const QChar curChar = cursor.document()->characterAt(cursor.position() - 1); + if (!closedNode->children.isEmpty() && curChar != QChar::LineSeparator) { + blockTagClosed = true; + } + } + break; default: if (closedNode->isBlock()) blockTagClosed = true; -- cgit v1.2.3