Cherrypick Handle stripnewlines for plain text list to 23.04
Handle stripping new lines when the plain text input is a markdown list.
(cherry picked from commit a0ae8b28b2)
This commit is contained in:
committed by
Tobias Fella
parent
a3b4f05e2c
commit
566743bc19
@@ -151,12 +151,6 @@ QString TextHandler::handleRecievePlainText(Qt::TextFormat inputFormat, const bo
|
||||
// Strip mx-reply if present.
|
||||
m_dataBuffer.remove(TextRegex::removeRichReply);
|
||||
|
||||
if (stripNewlines) {
|
||||
m_dataBuffer.replace(QStringLiteral("<br>"), QStringLiteral(" "));
|
||||
m_dataBuffer.replace(QStringLiteral("<br />"), QStringLiteral(" "));
|
||||
m_dataBuffer.replace(u'\n', QStringLiteral(" "));
|
||||
}
|
||||
|
||||
// Escaping then unescaping allows < and > to be maintained in a plain text string
|
||||
// otherwise markdownToHTML will strip what it thinks is a bad html tag entirely.
|
||||
if (inputFormat == Qt::PlainText) {
|
||||
@@ -169,6 +163,14 @@ QString TextHandler::handleRecievePlainText(Qt::TextFormat inputFormat, const bo
|
||||
*/
|
||||
m_dataBuffer = markdownToHTML(m_dataBuffer);
|
||||
|
||||
if (stripNewlines) {
|
||||
m_dataBuffer.replace(QStringLiteral("<br>\n"), QStringLiteral(" "));
|
||||
m_dataBuffer.replace(QStringLiteral("<br>"), QStringLiteral(" "));
|
||||
m_dataBuffer.replace(QStringLiteral("<br />\n"), QStringLiteral(" "));
|
||||
m_dataBuffer.replace(QStringLiteral("<br />"), QStringLiteral(" "));
|
||||
m_dataBuffer.replace(u'\n', QStringLiteral(" "));
|
||||
}
|
||||
|
||||
// Strip all tags/attributes except code blocks which will be escaped.
|
||||
QString outputString;
|
||||
nextTokenType();
|
||||
@@ -193,6 +195,7 @@ QString TextHandler::handleRecievePlainText(Qt::TextFormat inputFormat, const bo
|
||||
outputString = unescapeHtml(outputString);
|
||||
}
|
||||
|
||||
outputString = outputString.trimmed();
|
||||
return outputString;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user