From 4337d0d5d8957a6914ac3797bc45f3460ae41903 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 10 Jul 2022 11:21:54 +0100 Subject: [PATCH] Removing all \n is incorrect as these are used to show linebreaks in the html formatted body. Instead use the CMARK_OPT_HARDBREAKS options so these softbreaks in the markdown string are converted to hard breaks
in the html. Also remove 2 step process to replace and straight replace with "" to ensure no real breaks are removed --- src/neochatroom.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index b4608da67..bbf1cb026 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -633,7 +633,7 @@ void NeoChatRoom::removeLocalAlias(const QString &alias) QString NeoChatRoom::markdownToHTML(const QString &markdown) { const auto str = markdown.toUtf8(); - char *tmp_buf = cmark_markdown_to_html(str.constData(), str.size(), CMARK_OPT_DEFAULT); + char *tmp_buf = cmark_markdown_to_html(str.constData(), str.size(), CMARK_OPT_HARDBREAKS); const std::string html(tmp_buf); @@ -641,11 +641,9 @@ QString NeoChatRoom::markdownToHTML(const QString &markdown) auto result = QString::fromStdString(html).trimmed(); - result.replace("", "
"); - result.replace(QRegularExpression("(
)*$"), ""); + result.replace("", ""); result.replace("

", ""); result.replace("

", ""); - result.replace("\n", "
"); return result; }