From c907aee653e7979e1e761461320ff2892a0d2836 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Thu, 16 Jul 2026 07:23:41 +0200 Subject: [PATCH] use Qt native MarkdownText for prose blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stop hand-rolling markdown with regex. Qt 6 Text supports textFormat: Text.MarkdownText natively — handles backticks, bold, italic, links, lists correctly. Code blocks and diffs still use our custom KSyntaxHighlighting rendering. --- gui/main.qml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/gui/main.qml b/gui/main.qml index c16e803..d3e0b4a 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -519,17 +519,7 @@ ApplicationWindow { // --- Chat block delegates --- - function linkifyPaths(text) { - // Escape HTML entities first - let escaped = text.replace(/&/g, '&').replace(//g, '>') - // Inline code: `text` → monospace styled span - escaped = escaped.replace(/`([^`\n]+)`/g, '$1') - // Convert newlines to
- escaped = escaped.replace(/\n/g, '
') - // Match /absolute/path or /absolute/path:line - escaped = escaped.replace(/(\/[\w\-.\/]+(?::\d+)?)/g, '$1') - return escaped - } + Component { id: userDelegate @@ -702,12 +692,12 @@ ApplicationWindow { id: proseSubDelegate Text { width: parent ? parent.width : implicitWidth - text: root.linkifyPaths(subBlock.content) + text: subBlock.content || "" wrapMode: Text.Wrap - textFormat: Text.RichText + textFormat: Text.MarkdownText color: palette.text font.pixelSize: Qt.application.font.pixelSize - lineHeight: 1.4 + lineHeight: 1.3 onLinkActivated: function(link) { Qt.openUrlExternally(link) }