|
1 | | -// A remark (mdast) plugin used only by the `markdown` block. |
2 | | -// |
3 | | -// Every other block type renders through the library's mrkdwn parser |
4 | | -// (utils/markdown_parser), which has a `slack_emoji` tokenizer rule. The |
5 | | -// `markdown` block instead renders through react-markdown + remark-gfm, and that |
6 | | -// pipeline has no emoji rule — so `:shortcode:` would otherwise show up as |
7 | | -// literal text. This plugin splits mdast text nodes on `:shortcode:` and emits |
8 | | -// placeholder elements (tag name `SLACK_EMOJI_TAG`) that markdown_block.tsx maps |
9 | | -// back to the SAME <SlackEmoji> component the mrkdwn parser uses. Reusing that |
10 | | -// component means custom emoji (consumer `hooks.emoji`), standard emoji |
11 | | -// (shortcode -> unicode / node-emoji), aliases and skin tones all behave |
12 | | -// identically across every block type, with no divergent logic. |
13 | | -// |
14 | | -// `code` (fenced) and `inlineCode` are literal mdast nodes whose content lives |
15 | | -// in `value`, not in child `text` nodes, so they are never split here — Slack |
16 | | -// does not interpolate emoji inside code, and neither do we. |
| 1 | +// remark/mdast plugin for the `markdown` block (react-markdown + remark-gfm), |
| 2 | +// which — unlike every other block type — has no emoji rule. It splits text |
| 3 | +// nodes on `:shortcode:` into `SLACK_EMOJI_TAG` placeholders that markdown_block |
| 4 | +// renders via the same <SlackEmoji> component the mrkdwn parser uses, so custom, |
| 5 | +// standard, alias and skin-tone emoji all match. Code spans/blocks are never split. |
17 | 6 |
|
18 | 7 | // Tag name emitted into the hast tree via `data.hName`. markdown_block.tsx maps |
19 | 8 | // this through react-markdown's `components` prop. |
|
0 commit comments