Skip to content

Spoiler math output when source message contains spoilers#12

Open
lethalNeutrino wants to merge 3 commits into
mainfrom
feat/math-spoilers
Open

Spoiler math output when source message contains spoilers#12
lethalNeutrino wants to merge 3 commits into
mainfrom
feat/math-spoilers

Conversation

@lethalNeutrino
Copy link
Copy Markdown
Member

@lethalNeutrino lethalNeutrino commented Apr 27, 2026

Summary

  • If the source message contains any Discord spoiler syntax (||text||), the rendered math image(s) are sent as spoiler attachments (blurred until clicked)
  • Adds a SPOILER_RE regex to detect spoiler tags in the original message content
  • Passes a spoiler flag through process_math -> MathView -> discord.File
  • Covers all entry points: $...$ auto-detection, ```tex code blocks, and !tex/`!typst` commands

Test plan

  • Send a message like ||$x^2$|| and verify the output image is spoilered
  • Send a normal $x^2$ and verify the output is not spoilered
  • Send a message with a spoilered code block and verify spoiler behavior
  • Switch renderers via the dropdown and verify spoiler persists

Generated with Devin


Open in Devin Review

If the source message contains any Discord spoiler syntax (||text||),
the rendered math image(s) will be sent with spoiler=True so they
appear blurred until the viewer clicks to reveal.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Strip code block (```...```) and inline code (`...`) regions from
message content before searching for spoiler patterns. This prevents
false positives when || (norm notation) appears inside code blocks.

Co-Authored-By: Andrew Liu <landrew7363@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

…locks

When a code block is directly wrapped in spoiler tags (e.g. ||<code>||),
stripping code to empty string left |||| which SPOILER_RE couldn't match.
Replacing with a space preserves the spoiler structure (|| ||).

Co-Authored-By: Andrew Liu <landrew7363@gmail.com>
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.

2 participants