From d67e986384ad6cdf954d81d26b688cad636ef9cb Mon Sep 17 00:00:00 2001 From: El-Patronum <193477218+El-Patronum@users.noreply.github.com> Date: Mon, 17 Aug 2026 14:14:00 +0200 Subject: [PATCH] Fix markdown-table
cell overflow Models (notably thinking-mode) emit
for in-cell line breaks in markdown tables. Foundation's AttributedString(markdown:) returns raw HTML as literal tag text, so the cell rendered '
' verbatim AND kept the whole cell as one unbreakable token that overflowed the fixed column frame into its neighbour (the "pile of overlapping text"). Convert
variants to real newlines at the single cell choke point (AssistantMarkdownView.inline) so cells wrap. Comparison operators are untouched: the pattern requires the literal 'br'. Fixes #272. --- .../Primitives/AssistantMarkdownView.swift | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/MTPLXApp/Sources/MTPLXAppHost/Views/Chat/Primitives/AssistantMarkdownView.swift b/apps/MTPLXApp/Sources/MTPLXAppHost/Views/Chat/Primitives/AssistantMarkdownView.swift index 5eb67b6b..36ca6c08 100644 --- a/apps/MTPLXApp/Sources/MTPLXAppHost/Views/Chat/Primitives/AssistantMarkdownView.swift +++ b/apps/MTPLXApp/Sources/MTPLXAppHost/Views/Chat/Primitives/AssistantMarkdownView.swift @@ -511,12 +511,26 @@ private struct AssistantTableView: View { } private static func inline(_ text: String) -> AttributedString { - (try? AttributedString( - markdown: text, + // Models (notably thinking-mode) emit
for in-cell line breaks in + // markdown tables. cmark hands raw HTML back as literal tag text, so + // the cell would render "
" verbatim AND keep the whole cell as one + // unbreakable token that overflows the fixed column frame into its + // neighbour (the "pile of overlapping text"). Convert
variants to + // real newlines at this single choke point so cells wrap. Comparison + // operators ("a < b") are untouched: the pattern requires "br". + // ponytail:
only — other raw tags (, ) would still show + // raw; strip-all mangles "<"/">", add a tag allowlist if they appear. + let readable = text.replacingOccurrences( + of: #""#, + with: "\n", + options: [.regularExpression, .caseInsensitive] + ) + return (try? AttributedString( + markdown: readable, options: AttributedString.MarkdownParsingOptions( interpretedSyntax: .inlineOnlyPreservingWhitespace ) - )) ?? AttributedString(text) + )) ?? AttributedString(readable) } }