← Back to PRs

#20441: fix: preserve newlines for markdown table rendering in WebChat

by MisterGuy420 open 2026-02-18 23:02 View on GitHub →
size: XS trusted-contributor
Fixes #20410 ## What changed Preserve newlines before markdown parsing in Gateway WebChat so tables render as proper HTML tables instead of jammed inline text. ## AI-assisted contribution This fix was generated by an AI agent (OpenClaw cron: gh-issues-fix) ## Testing Validated with `pnpm build && pnpm check && pnpm test` ## Root cause The fix addresses the root cause by not collapsing newlines before the markdown parser runs. Changed text normalization in `extractTextFromChatContent` to preserve newlines while collapsing other whitespace. The regex change from `/\\s+/g` to `/[^\\S\\n]+/g` allows markdown tables and lists to render properly in the Gateway WebChat UI by maintaining line breaks that the markdown parser (`marked`) needs to recognize table syntax. --- **Greptile Summary** Changed text normalization in `extractTextFromChatContent` to preserve newlines while collapsing other whitespace. The regex change from `/\\s+/g` to `/[^\\S\\n]+/g` allows markdown tables and lists to render properly in the Gateway WebChat UI by maintaining line breaks that the markdown parser (`marked`) needs to recognize table syntax. **Confidence Score: 5/5** - This PR is safe to merge with minimal risk - The change is surgical (one regex modification), well-documented with inline comments referencing the issue, includes updated test coverage, and the regex pattern `/[^\\S\\n]+/g` is a standard technique for preserving newlines while normalizing other whitespace - The PR passed the full test suite (`pnpm build && pnpm check && pnpm test`) - Usage analysis shows that code paths with custom normalization functions bypass this change, limiting the impact scope to only those relying on the default behavior - No files require special attention <sub>Last reviewed commit: 5eecc8b</sub>

Most Similar PRs