diff --git a/gui/chatblockmodel.cpp b/gui/chatblockmodel.cpp index 53a0bb5..e83dd1d 100644 --- a/gui/chatblockmodel.cpp +++ b/gui/chatblockmodel.cpp @@ -151,7 +151,7 @@ QString ChatBlockModel::highlightCode(const QString &code, const QString &langua if (!def.isValid()) { delete repo; - return QStringLiteral("
") + escapeHtml(code).replace('\n', QStringLiteral("
")) + QStringLiteral("
"); + return QStringLiteral("
") + escapeHtml(code) + QStringLiteral("
"); } HtmlHighlighter builder; @@ -163,29 +163,29 @@ QString ChatBlockModel::highlightCode(const QString &code, const QString &langua for (int i = 0; i < lines.size(); ++i) { state = builder.processLine(lines[i], state); if (i < lines.size() - 1) - builder.html += QStringLiteral("
"); + builder.html += '\n'; } delete repo; - return QStringLiteral("
") + builder.html + QStringLiteral("
"); + return QStringLiteral("
") + builder.html + QStringLiteral("
"); } QString ChatBlockModel::renderDiff(const QString &diff) const { - QString html = QStringLiteral("
"); + QString html = QStringLiteral("
");
     const QStringList lines = diff.split('\n');
     for (const QString &line : lines) {
         if (line.startsWith('+')) {
-            html += QStringLiteral("") + escapeHtml(line) + QStringLiteral("
"); + html += QStringLiteral("") + escapeHtml(line) + QStringLiteral("\n"); } else if (line.startsWith('-')) { - html += QStringLiteral("") + escapeHtml(line) + QStringLiteral("
"); + html += QStringLiteral("") + escapeHtml(line) + QStringLiteral("\n"); } else if (line.startsWith("@@")) { - html += QStringLiteral("") + escapeHtml(line) + QStringLiteral("
"); + html += QStringLiteral("") + escapeHtml(line) + QStringLiteral("\n"); } else { - html += escapeHtml(line) + QStringLiteral("
"); + html += escapeHtml(line) + '\n'; } } - html += QStringLiteral("
"); + html += QStringLiteral(""); return html; } diff --git a/gui/main.qml b/gui/main.qml index 0636087..639cbde 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -716,12 +716,13 @@ ApplicationWindow { spacing: 0 // Rendered HTML (fenced code/diff) — shown when available - Label { + TextEdit { Layout.fillWidth: true visible: blockRenderedHtml && blockRenderedHtml.length > 0 text: blockRenderedHtml textFormat: Text.RichText - wrapMode: Text.WordWrap + readOnly: true + wrapMode: TextEdit.Wrap font.family: theme.fontFamily || "monospace" font.pointSize: theme.fontSize > 0 ? theme.fontSize : 12 color: theme.textColor