From b841f556d44d0afebe61d209ae0f81e641c8dd13 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Mon, 3 Aug 2026 00:24:52 +0200 Subject: [PATCH] gui: preserve newlines in plaintext blocks --- gui/chatblockmodel.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/gui/chatblockmodel.cpp b/gui/chatblockmodel.cpp index d14f910..08406e3 100644 --- a/gui/chatblockmodel.cpp +++ b/gui/chatblockmodel.cpp @@ -201,9 +201,13 @@ QString ChatBlockModel::renderMarkdown(const QString &markdown) const auto it = fenceRe.globalMatch(markdown); while (it.hasNext()) { const auto match = it.next(); - QTextDocument prose; - prose.setMarkdown(markdown.mid(cursor, match.capturedStart() - cursor)); - result += prose.toHtml(); + // Prose before this fence: HTML-escape and wrap in pre-wrap div to + // preserve newlines and whitespace. QTextDocument::setMarkdown would + // collapse single newlines (standard Markdown behavior). + const QString prose = markdown.mid(cursor, match.capturedStart() - cursor); + if (!prose.isEmpty()) + result += QStringLiteral("