Skip to content

fix: parseDiscordMarkdown() drops brackets off custom emoji/mentions (#99) - #100

Merged
otnc merged 1 commit into
mainfrom
fix/issue-99-discord-custom-emoji-markdown
Sep 3, 2026
Merged

fix: parseDiscordMarkdown() drops brackets off custom emoji/mentions (#99)#100
otnc merged 1 commit into
mainfrom
fix/issue-99-discord-custom-emoji-markdown

Conversation

@otnc

@otnc otnc commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #99.

parseInto() (src/text/discordMarkdown.ts) pushed token.content for every element outside WRAPPER_ELEMENTS — correct for code/codeBlock (the fence isn't meant to display), but wrong for emoji/mention/globalMention/roleMention/gameMention/channelMention/slashCommand: their .content is the same text with the outer <> stripped, discarding exactly the delimiter segment.ts's splitDiscord() later re-scans styled-run text for (<a?:name:id>) to substitute the actual emoji image. Once the brackets were gone, that regex could never match, so a custom Discord emoji rendered as broken literal text under markdown: 'discord'/true/false (and the deprecated stripDiscordMarkdown: true) — only markdown: 'raw' (skip parsing) worked.

Fix: push token.raw instead of token.content for that specific element set, so the bracketed syntax survives into the styled-run text.

Test plan

  • npm run ci (biome)
  • npm run typecheck
  • npm run test (877 tests, all green — new regression tests verified red against the pre-fix code, then green)
  • npm run build
  • npm run check:build (27 checks passed)

…h-command tokens

parseInto() pushed token.content for every element outside WRAPPER_ELEMENTS,
which is correct for code/codeBlock (the fence isn't meant to display) but
wrong for emoji/mention/globalMention/roleMention/gameMention/
channelMention/slashCommand — their .content is the same text with the
outer <>/delimiter stripped, discarding exactly the bracket that later
stages need to recognize the construct. segment.ts's splitDiscord() re-scans
already-parsed styled-run text for <a?:name:id> to substitute the actual
emoji image, and that regex can no longer match once the brackets are gone,
so a custom Discord emoji rendered as broken literal text under any markdown
mode that routes through this parser (discord/true/false).

Push token.raw instead of token.content for that specific set of element
kinds, so the bracketed syntax survives into the styled-run text.

Closes #99.
@otnc
otnc merged commit c5ff84e into main Sep 3, 2026
7 checks passed
@otnc
otnc deleted the fix/issue-99-discord-custom-emoji-markdown branch September 3, 2026 13:33
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.

Custom Discord emoji (<:name:id>) breaks under markdown: 'discord'/true/false — parseDiscordMarkdown() drops the brackets

1 participant