← Back to PRs

#18655: fix(mattermost): preserve markdown formatting and native tables

by echo931 open 2026-02-16 23:18 View on GitHub →
channel: mattermost size: S
## Summary Refresh of the old markdown/table work from stale PR #12809 onto current `main`. This keeps Mattermost message formatting intact by preserving block-level markdown structure when removing mentions, and restores native table rendering behavior. ## Changes - preserve leading indentation/newlines when stripping bot mention (`normalizeMention`) - add/refresh tests for mention normalization behavior - export `DEFAULT_TABLE_MODES` and assert runtime table-mode behavior via tests ## Validation - `pnpm exec vitest run extensions/mattermost/src/mattermost/monitor-helpers.test.ts src/config/markdown-tables.test.ts` Closes #12238 Refs #12245 <!-- greptile_comment --> <h3>Greptile Summary</h3> Refreshed markdown formatting preservation work from stale PR #12809. The changes ensure Mattermost messages maintain block-level markdown structure when removing bot mentions, and restore native table rendering by setting the default table mode to `off` for Mattermost. **Key Changes:** - Refactored `normalizeMention` to preserve leading indentation, newlines, and markdown formatting (headings, lists, blockquotes, code blocks) when stripping bot mentions - Exported `DEFAULT_TABLE_MODES` constant to enable testing - Added Mattermost to `DEFAULT_TABLE_MODES` map with `off` mode to render tables natively - Added comprehensive test coverage for mention normalization edge cases - Added tests to verify runtime table mode behavior The implementation properly handles markdown structure preservation by replacing mentions with empty strings (avoiding space injection) and only collapsing multiple spaces within lines while preserving leading indentation. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The changes are well-tested, focused, and straightforward. The `normalizeMention` refactor properly preserves markdown structure using a clear multi-step approach. The regex escaping is correct and matches existing patterns in the codebase. The table mode change is a simple configuration update with test coverage. The PR has excellent test coverage including edge cases for nested lists, code blocks, and various markdown formats. - No files require special attention <sub>Last reviewed commit: ae2824f</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs