Skip to content

Convert emoji shortcodes to native Slack emoji elements - #4

Closed
presmihaylov wants to merge 8 commits into
navidemad:mainfrom
presmihaylov:feat/emoji-shortcode-support
Closed

Convert emoji shortcodes to native Slack emoji elements#4
presmihaylov wants to merge 8 commits into
navidemad:mainfrom
presmihaylov:feat/emoji-shortcode-support

Conversation

@presmihaylov

Copy link
Copy Markdown
Contributor

Summary

  • Slack's rich_text blocks require emojis as explicit RichTextSectionEmojiElement objects — plain text shortcodes like :bar_chart: are rendered as literal text, not as emojis
  • Goldmark's emphasis parser splits text at underscores, fragmenting shortcodes like :bar_chart: into :bar_ + chart: across separate text elements
  • Added resolveEmojis() post-processing that merges adjacent same-style text elements (reassembling fragments) and converts detected :emoji_name: patterns into proper RichTextSectionEmojiElement objects
  • Applied in flushInlineToSection(), paragraph emission, and blockquote accumulation so emojis work in all contexts (paragraphs, lists, blockquotes, tables)

Changes

  • context.go — Added resolveEmojis(), mergeAdjacentText(), stylesEqual() helpers and emoji shortcode regex. Updated flushInlineToSection() to resolve emojis before flushing.
  • blocks.go — Applied resolveEmojis() in paragraph emission and blockquote accumulation paths.
  • renderer_test.go — Added TestConvert_EmojiShortcodes with 10 subtests covering: single emoji, embedded emoji, multiple emojis, underscore-containing names (speech_balloon), bold styling inheritance, non-emoji colon preservation, +1 emoji, list items, blockquotes, and JSON serialization. Added emoji seed to fuzz test.

Test plan

  • All 43 tests pass (33 existing + 10 new emoji tests)
  • Fuzz test updated with emoji input seed
  • No changes to public API — Convert() and ChunkBlocks() signatures unchanged

🤖 Generated with Claude Code

presmihaylov and others added 8 commits February 28, 2026 12:37
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tables previously rendered as ASCII art inside code-fenced SectionBlocks,
which wrapped poorly for long cell values. Slack's native TableBlock
(added Aug 2025) provides per-column wrapping and alignment. This change
upgrades slack-go to v0.18.0 and rewrites table rendering to use it.

Cells are now *RichTextBlock, so inline formatting (bold, links, code)
is preserved automatically instead of being stripped to plain text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Empty cells now get a minimal RichTextSection instead of producing
  "elements": null which the Slack API would reject
- Update Go version requirement from 1.22+ to 1.25+ in CLAUDE.md,
  README.md, and DEMO.md to match go.mod
- Fix stale doc.go prose still referencing SectionBlock for tables
- Update README.md table mapping for GFM tables
- Add TestConvert_TableEmptyCell test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Slack rejects messages with more than one table
(only_one_table_allowed). ChunkBlocks now forces a new chunk before
every additional TableBlock, in addition to the existing maxPerMessage
split.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add nil guard to emitBlock to prevent appending nil blocks
- Reset style stack at table cell entry to prevent style leaking
- Document ChunkBlocks table-per-chunk enforcement in README
- Add tests for multiple tables, mixed blocks, and code-in-cell

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Incorporates upstream feat/native-table-block changes (GFM tables now
render as native Slack TableBlocks with rich text cells and per-column
alignment). Fixes empty cell handling — Slack API rejects empty string
text elements, so use a space instead. Updates module path to fork.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Slack's rich_text blocks require emojis as explicit RichTextSectionEmojiElement
objects — plain text shortcodes like 📊 are rendered literally.
Goldmark's emphasis parser also splits text at underscores, fragmenting
shortcodes across multiple text elements.

Add post-processing in resolveEmojis() that merges adjacent text elements
with the same style and converts detected :emoji_name: patterns into
proper emoji elements. Applied in flushInlineToSection(), paragraph
emission, and blockquote accumulation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@presmihaylov

Copy link
Copy Markdown
Contributor Author

Closing in favor of a new PR based on upstream main (the original used the fork's module path).

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.

2 participants