Skip to content

fix(mattermost): preserve Markdown formatting + native tables#2

Merged
echo931 merged 3 commits intomainfrom
fix/mattermost-markdown-formatting
Feb 9, 2026
Merged

fix(mattermost): preserve Markdown formatting + native tables#2
echo931 merged 3 commits intomainfrom
fix/mattermost-markdown-formatting

Conversation

@echo931
Copy link
Copy Markdown
Collaborator

@echo931 echo931 commented Feb 9, 2026

Fixes three related Mattermost Markdown issues:

  • Inbound mention normalization collapsed newlines (used /\s+/), flattening block-level Markdown.
  • Mattermost table mode defaulted to "code", wrapping pipe tables in fenced code blocks.
  • When tableMode="code" and a message had tables, the whole message was re-rendered through the IR pipeline, degrading non-table block formatting.

Changes:

  • Preserve newlines in mention stripping (collapse only horizontal whitespace).
  • Default mattermost markdown.tables to "off" (Mattermost supports native tables).
  • Extract normalizeMention to monitor-helpers for testability.
  • Add unit tests.

Fixes openclaw#12247 openclaw#12245 openclaw#12238

Tests: pnpm vitest run extensions/mattermost/

… natively

Three related bugs in the Mattermost channel plugin:

1. normalizeMention() used \s+ replacement which collapsed newlines into
   spaces, destroying all block-level Markdown (headings, lists, blockquotes,
   task lists) in inbound messages. Fixed to only collapse horizontal
   whitespace (spaces/tabs) while preserving newlines.

2. DEFAULT_TABLE_MODES did not include mattermost, so it fell through to
   the "code" default which wraps tables in fenced code blocks. Mattermost
   clients render pipe tables natively, so the correct default is "off".

3. When tableMode was "code" and a message contained tables, the entire
   text was re-rendered through the IR pipeline which also stripped block
   formatting from non-table content.

Also extracted normalizeMention to monitor-helpers.ts for testability and
added unit tests for both fixes.

Fixes: openclaw#12247, openclaw#12245, openclaw#12238
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1702fa2b81

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +182 to +183
.replace(/[^\S\n]+/g, " ")
.replace(/ ?\n ?/g, "\n")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep leading indentation after mention removal

Collapsing all horizontal whitespace here still strips indentation that Markdown relies on, so messages like @bot\n- item\n - nested or indented code blocks lose structure after normalization (nested becomes a top-level list item, code block indentation is removed). This means the new mention-normalization path still corrupts common multi-line Markdown inputs in Mattermost whenever a bot mention is present.

Useful? React with 👍 / 👎.

…eedback)

Replaced blanket horizontal-whitespace collapse with a line-by-line approach
that only collapses runs of multiple spaces after non-space characters,
preserving leading indentation for nested lists and code blocks.
@isingasimplesong
Copy link
Copy Markdown
Collaborator

@codex what about that fix?

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

…of source text

Address review feedback: replace brittle fs.readFileSync source
inspection with direct import of the exported map.
@echo931 echo931 merged commit 78a5a7a into main Feb 9, 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.

[Bug]: Mattermost inbound messages lose newlines (multi-line Markdown received as single line)

2 participants