Skip to content

Fix markdown-table <br> cell overflow - #273

Open
El-Patronum wants to merge 1 commit into
youssofal:mainfrom
El-Patronum:fix/table-br-overflow-and-presets
Open

Fix markdown-table <br> cell overflow#273
El-Patronum wants to merge 1 commit into
youssofal:mainfrom
El-Patronum:fix/table-br-overflow-and-presets

Conversation

@El-Patronum

@El-Patronum El-Patronum commented Aug 17, 2026

Copy link
Copy Markdown

Fixes #272.

(This PR originally also carried an unrelated Profile sampling-presets feature. That has been dropped — this PR is now the bug fix alone. The branch name is a leftover from that earlier scope.)

Bug: markdown-table <br> cell overflow

Models (notably thinking-mode) emit <br> for in-cell line breaks in markdown tables. AssistantMarkdownView.inline(_:) hands the raw cell substring to Foundation's AttributedString(markdown:), which returns raw-HTML nodes as literal tag text — so the cell rendered <br> verbatim and kept the whole cell as one unbreakable token that overflowed the fixed column frame into its neighbour (the "pile of overlapping text").

Both symptoms trace to that one mechanism in one function — the single choke point every table cell routes through.

Fix

Normalize <br> variants to real newlines at that choke point, before markdown attribution, so cells wrap:

let readable = text.replacingOccurrences(
    of: #"<br\s*/?>"#,
    with: "\n",
    options: [.regularExpression, .caseInsensitive]
)

Comparison operators (a < b) are untouched — the pattern requires the literal br.

Known ceiling, marked with a deliberate ponytail: comment: other raw tags (<b>, <span>) would still render raw. A blanket tag-strip was rejected because it mangles bare </> (verified: a < b and c > da d). If those tags show up in practice, the follow-up is a tag allowlist at the same choke point.

Proof

  • Verified before/after against the real AttributedString(markdown:) API:
    • before: "foo<br>bar<br>baz""foo<br>bar<br>baz" (one unbreakable line, literal tags)
    • after: "foo<br>bar<br>baz""foo\nbar\nbaz" (three wrappable lines, no tags)
  • swift build clean on this branch, no new warnings in the touched file.
  • swift test: 574 tests, 0 failures. (A timing-sensitive daemon-supervisor test in MTPLXAppCore flakes under the full run on this machine but passes in isolation, with and without this change; it is unreachable from this view-only diff.)

@El-Patronum
El-Patronum requested a review from youssofal as a code owner August 17, 2026 10:41
Models (notably thinking-mode) emit <br> for in-cell line breaks in
markdown tables. Foundation's AttributedString(markdown:) returns raw
HTML as literal tag text, so the cell rendered '<br>' 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 <br> 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 youssofal#272.
@El-Patronum
El-Patronum force-pushed the fix/table-br-overflow-and-presets branch from 483cd92 to d67e986 Compare August 17, 2026 12:14
@El-Patronum El-Patronum changed the title Fix markdown-table <br> cell overflow; add Profile sampling presets Fix markdown-table <br> cell overflow Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown tables render raw <br> and overflow into neighbouring columns

1 participant