diff --git a/retroshare-gui/src/gui/chat/HandleRichText.cpp b/retroshare-gui/src/gui/chat/HandleRichText.cpp index 2304f92c7..eed0f5583 100644 --- a/retroshare-gui/src/gui/chat/HandleRichText.cpp +++ b/retroshare-gui/src/gui/chat/HandleRichText.cpp @@ -269,4 +269,17 @@ void optimizeHtml(QTextEdit *textEdit, QString &text) std::cerr << "Optimized text to " << text.length() << " bytes , instead of " << textEdit->toHtml().length() << std::endl; } +QString toHtml(QString text, bool realHtml) +{ + // replace "\n" from the optimized html with "
" + text.replace("\n", "
"); + if (!realHtml) { + return text; + } + + QTextDocument doc; + doc.setHtml(text); + return doc.toHtml(); +} + } // namespace RsHtml diff --git a/retroshare-gui/src/gui/chat/HandleRichText.h b/retroshare-gui/src/gui/chat/HandleRichText.h index 174e6a4c3..dfe9ce6b2 100644 --- a/retroshare-gui/src/gui/chat/HandleRichText.h +++ b/retroshare-gui/src/gui/chat/HandleRichText.h @@ -113,7 +113,8 @@ extern EmbedInHtmlImg defEmbedImg; QString formatText(const QString &text, unsigned int flag); bool findAnchors(const QString &text, QStringList& urls); -void optimizeHtml(QTextEdit *textEdit, QString &text); +void optimizeHtml(QTextEdit *textEdit, QString &text); +QString toHtml(QString text, bool realHtml = true); } // namespace RsHtml diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 1a867104b..1a63ff7dc 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -1018,7 +1018,7 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all) msgComposer->insertTitleText(QString::fromStdWString(msgInfo.title), REPLY); QTextDocument doc ; - doc.setHtml(QString::fromStdWString(msgInfo.msg)); + doc.setHtml(RsHtml::toHtml(QString::fromStdWString(msgInfo.msg), false)); msgComposer->insertPastedText(doc.toPlainText()); msgComposer->addRecipient(MessageComposer::TO, msgInfo.srcId, false); @@ -1062,7 +1062,7 @@ MessageComposer *MessageComposer::forwardMsg(const std::string &msgId) msgComposer->insertTitleText(QString::fromStdWString(msgInfo.title), FORWARD); QTextDocument doc ; - doc.setHtml(QString::fromStdWString(msgInfo.msg)) ; + doc.setHtml(RsHtml::toHtml(QString::fromStdWString(msgInfo.msg), false)); msgComposer->insertForwardPastedText(doc.toPlainText());