Fix double quoting and missing new lines in message sent

* Don't encode text inside code block
* Make sure to replace \n with <br> in the html rendering. It's not
  respecting the common mark spec but this is the same behavior as
  Element
This commit is contained in:
Carl Schwan
2021-10-23 15:58:07 +02:00
committed by Tobias Fella
parent a146fab5a0
commit f2cf82ee8e

View File

@@ -106,7 +106,20 @@ void ActionsHandler::postMessage(const QString &text,
CustomEmojiModel *cem)
{
QString rawText = text;
QString cleanedText = text.toHtmlEscaped();
auto stringList = text.split(QStringLiteral("```"));
QString cleanedText;
const auto count = stringList.count();
for (int i = 0; i < count; i++) {
if (i % 2 == 0) {
if (i + 1 != count) {
cleanedText += stringList[i].toHtmlEscaped() + QStringLiteral("```");
} else {
cleanedText += stringList[i].toHtmlEscaped();
}
} else {
cleanedText += stringList[i] + QStringLiteral("```");
}
}
auto preprocess = [cem](const QString &it) -> QString {
if (cem == nullptr) {