Skip to content

Commit 4dadd71

Browse files
committed
chore: ✏️ condense long code comments
Trim the plugin and test file headers and the MarkdownEmoji comment to five lines or fewer. https://claude.ai/code/session_01Qea1JoBqVXi6R8Fw3QWCr7
1 parent 885661e commit 4dadd71

3 files changed

Lines changed: 13 additions & 33 deletions

File tree

src/components/blocks/markdown_block.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ type MarkdownBlockProps = {
88
data: MarkdownBlock;
99
};
1010

11-
// Renders the placeholder element emitted by remarkSlackEmoji through the same
12-
// <SlackEmoji> component the mrkdwn parser uses, so the `markdown` block honors
13-
// custom emoji (`hooks.emoji`), standard emoji, aliases and skin tones exactly
14-
// like every other block type. The emoji name is read from the hast node's
15-
// properties (set via `hProperties` in the remark plugin).
11+
// Renders the placeholder emitted by remarkSlackEmoji through the same
12+
// <SlackEmoji> component the mrkdwn parser uses (so custom/standard/alias/
13+
// skin-tone emoji match). The emoji name comes from the hast node properties.
1614
const MarkdownEmoji = ({ node }: { node?: { properties?: { name?: unknown } } }) => {
1715
const name = typeof node?.properties?.name === "string" ? node.properties.name : "";
1816
return <SlackEmoji element={{ type: "slack_emoji", value: name }} />;

src/utils/remark_slack_emoji.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
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.
176

187
// Tag name emitted into the hast tree via `data.hName`. markdown_block.tsx maps
198
// this through react-markdown's `components` prop.

test/markdown_emoji.test.mjs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
// Emoji interpolation in the `markdown` block.
2-
//
3-
// The `markdown` block renders through react-markdown + remark-gfm (unlike every
4-
// other block type, which uses the mrkdwn parser). It previously had no emoji
5-
// rule, so `:shortcode:` rendered as literal text. These tests lock in that the
6-
// markdown block now interpolates emoji identically to the mrkdwn blocks —
7-
// standard, aliases, skin tones, and custom emoji via `hooks.emoji` — while
8-
// leaving code spans untouched.
9-
//
10-
// They run against the built package (dist/) so no test framework / transform
11-
// is needed: just Node's built-in runner + react-dom/server. CI builds before
12-
// running tests.
1+
// Emoji interpolation in the `markdown` block — it renders through react-markdown
2+
// (not the mrkdwn parser) and previously showed `:shortcode:` as literal text.
3+
// These lock in parity with mrkdwn blocks: standard, aliases, skin tones, custom
4+
// emoji via hooks, and code-span exclusion. Run against the built dist/ via Node's
5+
// built-in runner (no test framework needed); CI builds before testing.
136

147
import test from "node:test";
158
import assert from "node:assert/strict";

0 commit comments

Comments
 (0)