fix: parseDiscordMarkdown() drops brackets off custom emoji/mentions (#99) - #100
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #99.
parseInto()(src/text/discordMarkdown.ts) pushedtoken.contentfor every element outsideWRAPPER_ELEMENTS— correct forcode/codeBlock(the fence isn't meant to display), but wrong foremoji/mention/globalMention/roleMention/gameMention/channelMention/slashCommand: their.contentis the same text with the outer<>stripped, discarding exactly the delimitersegment.ts'ssplitDiscord()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 undermarkdown: 'discord'/true/false(and the deprecatedstripDiscordMarkdown: true) — onlymarkdown: 'raw'(skip parsing) worked.Fix: push
token.rawinstead oftoken.contentfor that specific element set, so the bracketed syntax survives into the styled-run text.Test plan
npm run ci(biome)npm run typechecknpm run test(877 tests, all green — new regression tests verified red against the pre-fix code, then green)npm run buildnpm run check:build(27 checks passed)