Skip to content

Fix /spoiler command not converting markdown to HTML - #35103

Draft
jasonjose007 wants to merge 2 commits into
element-hq:developfrom
jasonjose007:worktree-gsoc-spoiler-fix
Draft

jasonjose007 wants to merge 2 commits into
element-hq:developfrom
jasonjose007:worktree-gsoc-spoiler-fix

Conversation

@jasonjose007

@jasonjose007 jasonjose007 commented Sep 17, 2026

Copy link
Copy Markdown

Fixes #21185

The /spoiler slash command was inserting raw message text directly into the formatted_body HTML span, so markdown (e.g. **bold**) and newlines were never processed into HTML.

Before:
"formatted_body": "<span data-mx-spoiler>**secret** message</span>"

After:
"formatted_body": "<span data-mx-spoiler><p><strong>secret</strong> message</p></span>"

Change

In apps/web/src/slash-commands/SlashCommands.tsx, run message through the already-imported htmlSerializeFromMdIfNeeded (with forceHTML: true) before wrapping it in the spoiler span — matching how the rest of the message pipeline handles content.

Test plan

  • /spoiler **bold** produces <strong>bold</strong> inside the span
  • /spoiler plain text renders correctly
  • All 102 existing slash-command unit tests pass

The spoiler slash command was inserting the raw message text directly into
the formatted_body HTML span, so markdown syntax and special characters
were never processed. Run the message through htmlSerializeFromMdIfNeeded
so that e.g. **bold** becomes <strong>bold</strong> inside the spoiler span.

Fixes element-hq#21185

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Sep 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the Z-Community-PR Issue is solved by a community member's PR label Sep 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/spoiler command does not convert to html

2 participants