Add emoji interpolation to markdown blocks#74
Merged
Conversation
The `markdown` block renders through react-markdown + remark-gfm, which had no emoji rule, so `:shortcode:` (custom and standard) rendered as literal `:name:` text — unlike every other block type, which goes through the mrkdwn parser's slack_emoji rule. Add a `remarkSlackEmoji` plugin that splits mdast text nodes on `:shortcode:` (skipping inline and fenced code) and renders them through the same <SlackEmoji> component the mrkdwn parser uses, so custom emoji (hooks.emoji), standard emoji, aliases and skin tones all behave identically across block types. Tests cover the new behavior via Node's built-in test runner (no new deps) against the built package. https://claude.ai/code/session_01Qea1JoBqVXi6R8Fw3QWCr7
Reframe the playground fixture as a standard deploy-summary message instead of a "now emoji work" demo, while still exercising emoji in a header, prose, list items, a skin tone and an alias. https://claude.ai/code/session_01Qea1JoBqVXi6R8Fw3QWCr7
Trim the plugin and test file headers and the MarkdownEmoji comment to five lines or fewer. https://claude.ai/code/session_01Qea1JoBqVXi6R8Fw3QWCr7
eaf991e to
4dadd71
Compare
commit: |
Owner
|
Thanks for this @StephenTangCook — really clean contribution. I built the branch locally and rendered it through ReactDOMServer, and the behaviour all checks out: emoji shortcodes interpolate in markdown blocks now, and crucially the output matches the section/mrkdwn path for the same text, which is exactly the parity goal. Nice work reusing instead of duplicating the emoji logic, and the recursion into child nodes means it works in headings, bold, lists, blockquotes, and link text too. Code spans and fenced blocks correctly stay literal, and the hooks.emoji path fires as expected. Your 7 tests pass. Here are the blocks I used to verify, in case they’re useful: Overall this is solid — happy to see it land. 👍 |
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
The
markdownblock now interpolates Slack emoji shortcodes (:shortcode:), bringing it to feature parity with other block types that use the mrkdwn parser. Previously, emoji shortcodes rendered as literal text in markdown blocks becausereact-markdown+remark-gfmhad no emoji rule.Key Changes
src/utils/remark_slack_emoji.ts): A lightweight mdast plugin that splits text nodes on:shortcode:patterns and emits placeholder elements, while preserving emoji inside code spans and fenced code blockssrc/components/blocks/markdown_block.tsx): Integrated the new plugin into the remark pipeline and mapped the placeholder elements to the existing<SlackEmoji>component, ensuring custom emoji (hooks.emoji), standard emoji, aliases, and skin tones all behave identically across block typestest/markdown_emoji.test.mjs): Node.js tests covering standard shortcodes, aliases, skin-tone modifiers, custom emoji via hooks, and code span/block preservationplayground/src/fixtures.ts): Added a demo showcasing emoji rendering in markdown blocks alongside code examples.github/workflows/main.yml,package.json): Added test execution to the build pipelineImplementation Details
slack_emojitokenizer to ensure consistent shortcode matchingcodeandinlineCode) are never split, preserving Slack's behavior of not interpolating emoji in code<SlackEmoji>component rather than duplicating emoji logic, eliminating divergent behavior between block types@types/mdastas a dependencyhttps://claude.ai/code/session_01Qea1JoBqVXi6R8Fw3QWCr7