Roles and users can be pinged inside of code blocks

(#403) Bug Fixed markdown notifications

Summary

When adding a role or user ping inside of a code block, the ping is still created.

Steps to reproduce

  1. Get the ID of a role or user.
  2. Write <@&id> (for a role) or <@id> (for a user) inside of a code block (```), where "id" is the role or user ID
  3. Send the message. The role or user will be pinged.

Environment (optional)

stable build 87 (28da28c), 2026-03-11 14:24:05 UTC, Chrome 144.0.0.0, Linux (x86)

Logs or screenshots (optional)

image image
  • 561884707-8f31ddf4-71ed-404b-98eb-bac623339152.png

    561884707-8f31ddf4-71ed-404b-98eb-bac623339152.png

    373×160 | 13 kB

  • 561886019-12f5262c-70a9-4b65-acbb-9ffeccf2bd8f.png

    561886019-12f5262c-70a9-4b65-acbb-9ffeccf2bd8f.png

    332×159 | 12 kB

2 comments

Sign in with Fluxer to comment and vote.
Comment by ternera
terneraMod 1 vote originally by @ternera on GitHub
Can reproduce with single and triple backtick codeblocks. image stable build 87 (28da28c), 2026-03-11 14:24:05 UTC, Electron 39.2.7, macOS 26.3.1 (arm64), desktop stable 0.0.8
  • 561906415-312e1b23-afd4-4b89-b5f7-ea11c2df53dd.png

    561906415-312e1b23-afd4-4b89-b5f7-ea11c2df53dd.png

    1120×188 | 31 kB

Comment by @cproudlock
RexSystem 1 vote originally by @cproudlock on GitHub
The rendering side is fine — code blocks display mentions as plain text. The issue is that notifications are still triggered for mentions inside code blocks. The mention parsing in packages/markdown_parser/src/parsers/InlineParsers.tsx (around lines 270-339) processes mentions unconditionally without checking whether they're inside a code block context. The block parser (BlockParsers.tsx) handles code blocks at a higher level, but the notification extraction layer doesn't consult the AST to check whether a mention node is a child of a CodeBlock node. The fix should be applied wherever mentions are extracted for notification purposes (not in the renderer, which already handles this correctly). Before triggering a notification for a mention, the code should walk up the AST to verify the mention isn't inside a CodeBlock or InlineCode node.