Summary: | Kmail removes empty lines in HTML | ||
---|---|---|---|
Product: | [Unmaintained] kmail | Reporter: | Tomas <nicco.ts> |
Component: | general | Assignee: | kdepim bugs <kdepim-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | bielen, business, masaj, mathias.v44, rado.kljucevsek |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Tomas
2009-09-18 13:11:08 UTC
This was a Qt bug we worked around in KDE. With Qt 4.5.2, this seems to be fixed, and we removed the workaround, since it was causing other problems. At least here it works, we even have a unit test for that now, in kdelibs. (In reply to comment #1) > This was a Qt bug we worked around in KDE. > With Qt 4.5.2, this seems to be fixed, and we removed the workaround, since it > was causing other problems. > > At least here it works, we even have a unit test for that now, in kdelibs. Hi Thomas, I have libqt4-452 since 2nd July: libqt4-4.5.2-51.1 Thu 02 Jul 2009 10:08:18 PM CEST but I noticed this issue after last upgrade: kontact-4.3.1-160.1 Wed 16 Sep 2009 02:56:16 PM CEST kmail-4.3.1-160.1 Wed 16 Sep 2009 02:53:56 PM CEST For me it seems to be not working without the workaround you had mentioned. Version: (using KDE 4.3.1) OS: Linux Installed from: Fedora 10 kdepim: 4.3.1-1.fc10 qt: 4.5.2-3.fc10 Architecture: x86_64 I experienced the same problem with the latest upgrade to 4.3.1. This bug finally disappeared with 4.3.0. for me but it is here again. It completely ruins the view of a e-mail after it has been sent out. This can be seen afterward in the preview window. Strange enough if you try to resend such an e-mail the composer shows you the originally formatted text. For me it is a nightmare. I will have to resend some messages and apologize to people because of the mess they received, all my new messages will have to be without HTML formatting, I have to change my signature, ... Please fix it with high priority or revert back. Thank you. (In reply to comment #3) > Version: (using KDE 4.3.1) > OS: Linux > Installed from: Fedora 10 > kdepim: 4.3.1-1.fc10 > qt: 4.5.2-3.fc10 > Architecture: x86_64 > > I experienced the same problem with the latest upgrade to 4.3.1. This bug > finally disappeared with 4.3.0. for me but it is here again. It completely > ruins the view of a e-mail after it has been sent out. This can be seen > afterward in the preview window. Strange enough if you try to resend such an > e-mail the composer shows you the originally formatted text. > > For me it is a nightmare. I will have to resend some messages and apologize to > people because of the mess they received, all my new messages will have to be > without HTML formatting, I have to change my signature, ... > > Please fix it with high priority or revert back. Thank you. I'm pleased I'm not alone in this problem. Nightmare called HTML support in KMail continue. Problem is, Kmail is the best e-mail client for KDE, apart HTML support, otherwise I would use Zimbra (It has great HTML support, same as Evolution or Thunderbird, but LDAP search in exchange contacts is missing). *** Bug 194378 has been marked as a duplicate of this bug. *** I can experience exactly the same problem running KMail 1.12.1 under KDE 4.3.1, on Fedora 11. kdepim-4.3.1-5.fc11.x86_64 qt-4.5.2-3.fc11.x86_64 I confirm this is a very annoying bug since the presentation of an email becomes awful as soon as we send it. Please fix it. Guys don't worry. kdepim-kmail 4.3.2-1 qt 4.5.3-2 Still not repaired. I'm very dissapointed, it's nice that Kontact contains a lot of modules and pretty things, but basic HTML support is still not supported, for that it becomes kind of "useful" in all ways.. @masaj. Let's do it the OSS way. Instead of just complain (we're sorry, but fixing > 1000 bugs in the spare time is not a speedy task), help KDE sorting out which bugs are still valid, just try to reproduce them. Join the bugsquad in that task. http://techbase.kde.org/Contribute/Bugsquad More information why this is happening is here: http://osdir.com/ml/kdepim-bugs/2009-11/msg00075.html The settings margin-top:0px; margin-bottom:0px; make the problem. This shouldn't be too hard to fix as the cause is known? At least this bug can be finally confirmed ... Now it is OK in Kmail, but other e-mail client see it without empty lines: Bug 229527 Bug 229527 still exists in kmail-4.4.3-210.5 *** This bug has been confirmed by popular vote. *** commit 366e26a75817bcf246bfe04453c5f69e198eee93 branch master Author: Torgny Nyblom <kde@nyblom.org> Date: Sat Jan 1 21:17:50 2011 +0100 Do not remove empty lines in HTML for Outlook Thanks to Frank Vanderham for the patch. BUG: 207779 diff --git a/messagecomposer/CMakeLists.txt b/messagecomposer/CMakeLists.txt index 477bc29..53933fa 100644 --- a/messagecomposer/CMakeLists.txt +++ b/messagecomposer/CMakeLists.txt @@ -84,7 +84,7 @@ kde4_add_kcfg_files(messagecomposer_src kde4_add_library( messagecomposer ${LIBRARY_TYPE} ${messagecomposer_src} ) target_link_libraries( messagecomposer ${KDE4_KIO_LIBS} ${KDEPIMLIBS_KMIME_LIBS} ${KDEPIMLIBS_AKONADI_KMIME_LIBS} ${KDEPIMLIBS_AKONADI_LIBS} ${KDEPIMLIBS_MAILTRANSPORT_LIBS} ${KDEPIMLIBS_KPIMTEXTEDIT_LIBS} ${KDEPIMLIBS_KPIMIDENTITIES_LIBS} - messagecore messageviewer templateparser kleo kdepim ${QGPGME_LIBRARIES} ) + messagecore messageviewer templateparser kleo kdepim ${QGPGME_LIBRARIES} ${QT_QTWEBKIT_LIBRARY} ) set_target_properties( messagecomposer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install( TARGETS messagecomposer ${INSTALL_TARGETS_DEFAULT_ARGS} ) diff --git a/messagecomposer/kmeditor.cpp b/messagecomposer/kmeditor.cpp index 7ab1288..30e9b4c 100644 --- a/messagecomposer/kmeditor.cpp +++ b/messagecomposer/kmeditor.cpp @@ -39,6 +39,10 @@ #include <QShortcut> #include <QTextLayout> #include <QTimer> +#include <QWebElement> +#include <QWebElementCollection> +#include <QWebFrame> +#include <QWebPage> using namespace KPIMTextEdit; @@ -686,4 +690,39 @@ void KMeditor::fillComposerTextPart ( TextPart* textPart ) const } } +QString KMeditor::toCleanHtml() const +{ + const QString textEditHTML = toHtml(); + + // construct a non-visual QWebPage - that'll hook us into Qt's HTML parser from WebKit + QWebPage webpage( 0 ); + QWebFrame *webframe = webpage.mainFrame(); + webframe->setHtml( textEditHTML ); + QWebElement docElement = webframe->documentElement(); + + // fix 1 - empty lines should show as empty lines - MS Outlook treats margin-top:0px; as + // a non-existing line. + // Although we can simply remove the margin-top style property, we still get unwanted results + // if you have three or more empty lines. It's best to replace empty <p> elements with <br>. + // As per http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict, <br> elements are still proper + // HTML. + QWebElementCollection paragraphs = docElement.findAll( QString::fromAscii( "p" ) ); + foreach (QWebElement paraElement, paragraphs) { + QString paraContent = paraElement.toPlainText(); + // Only make a change when the paragraph content is empty + if ( paraContent.isEmpty() ) { + paraElement.replace( QString::fromAscii( "<br />" ) ); + } + } + // fix 2 - ordered and unordered lists - MS Outlook treats margin-left:0px; as + // a non-existing number; e.g: "1. First item" turns into "First Item" + QWebElementCollection lists = docElement.findAll( QString::fromAscii( "ol,ul" ) ); + foreach (QWebElement listElement, lists) { + //TODO in the future, we may want to explicitly set the margin-left=0 with the Composer window itself, which + // would be overwritten here again. This will likely require a rewrite of the KMEditor altogether, though. + listElement.setStyleProperty( QString::fromAscii( "margin-left" ), QString( ) ); + } + return webframe->toHtml(); +} + #include "kmeditor.moc" diff --git a/messagecomposer/kmeditor.h b/messagecomposer/kmeditor.h index af9bf89..b24e3ba 100644 --- a/messagecomposer/kmeditor.h +++ b/messagecomposer/kmeditor.h @@ -176,6 +176,12 @@ class MESSAGECOMPOSER_EXPORT KMeditor : public KPIMTextEdit::TextEdit */ void fillComposerTextPart( Message::TextPart* textPart ) const; + /** + * Overloaded function from KRichTextEdit to deal with problems viewing HTML formatted + * emails in MS Outlook. + */ + QString toCleanHtml() const; + public Q_SLOTS: void slotAddQuotes(); SVN commit 1211736 by tmcguire: Fix the HTML output in cleanHTML() again. This fixes MS Outlook not displaying mails from KMail correctly. Thanks to "Frank Vanderham" <twelve dot eighty at gmail dot com> for the patch! BUG: 207779 M +41 -3 krichtextedit.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1211736 SVN commit 1211745 by aacid: Backport r1211736 | tmcguire | 2011-01-04 19:15:21 +0000 (dt, 04 gen 2011) | 10 lines Fix the HTML output in cleanHTML() again. This fixes MS Outlook not displaying mails from KMail correctly. Thanks to "Frank Vanderham" <twelve dot eighty at gmail dot com> for the patch! BUG: 207779 M +41 -3 krichtextedit.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1211745 SVN commit 1211746 by aacid: Backport r1211736 | tmcguire | 2011-01-04 19:15:21 +0000 (dt, 04 gen 2011) | 10 lines Fix the HTML output in cleanHTML() again. This fixes MS Outlook not displaying mails from KMail correctly. Thanks to "Frank Vanderham" <twelve dot eighty at gmail dot com> for the patch! BUG: 207779 M +41 -3 krichtextedit.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1211746 |