Skip to content

Add emoji shortcode conversion and enforce Slack table limits - #8

Merged
navidemad merged 2 commits into
mainfrom
feat/emoji-and-table-limits
Mar 6, 2026
Merged

Add emoji shortcode conversion and enforce Slack table limits#8
navidemad merged 2 commits into
mainfrom
feat/emoji-and-table-limits

Conversation

@navidemad

Copy link
Copy Markdown
Owner

Summary

  • Convert emoji shortcodes (:bar_chart:, :+1:, :wave:) into native RichTextSectionEmojiElement objects — Slack renders plain text shortcodes as literal text, not emojis
  • Merge adjacent same-style text elements before emoji scanning to reassemble shortcodes fragmented by goldmark's underscore-splitting emphasis parser (e.g. :bar_chart::bar_ + chart:)
  • Reject numeric-only emoji names (e.g. :49: from timestamps like 19:49:41) that cause Slack invalid_blocks errors
  • Enforce Slack TableBlock API limits: split tables exceeding 100 rows into multiple TableBlocks (each carrying the same header), truncate columns beyond 20

Changes

  • context.go — Added emojiShortcodeRe, isValidEmojiName(), resolveEmojis(), mergeAdjacentText(), stylesEqual(). Updated flushInlineToSection() to resolve emojis before flushing.
  • blocks.go — Applied resolveEmojis() in blockquote accumulation and paragraph emission paths.
  • table.go — Added maxTableRows/maxTableColumns constants. Renamed renderTableBlockrenderTableBlocks with row splitting, column truncation, and extracted buildColumnSettings()/truncateRow() helpers.
  • renderer_test.go — Added 12 emoji subtests (shortcodes, underscore names, bold inheritance, non-emoji colons, list/blockquote contexts, numeric rejection) and 4 table limit tests (150-row split, exact-at-limit, 25-column truncation, 200-row 3-way split). Added emoji fuzz seed.

Test plan

  • All 99 tests pass (go test ./... -v)
  • go vet ./... clean
  • No changes to public API — Convert() and ChunkBlocks() signatures unchanged

🤖 Generated with Claude Code

navidemad and others added 2 commits March 6, 2026 16:20
Convert emoji shortcodes (e.g. 📊) into native
RichTextSectionEmojiElement objects so Slack renders them as actual
emojis. Goldmark's emphasis parser splits text at underscores,
fragmenting shortcodes — resolveEmojis() merges adjacent same-style
text elements before scanning for shortcodes. Numeric-only patterns
like :49: from timestamps are rejected to avoid Slack invalid_blocks
errors.

Enforce Slack TableBlock API limits: tables exceeding 100 rows are
split into multiple TableBlocks (each carrying the same header), and
columns beyond 20 are silently truncated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Skip emoji shortcode scanning for code-styled text elements so
  backtick-wrapped shortcodes like `:fire:` render as literal text
- Fix misleading comments on emojiShortcodeRe and isValidEmojiName
- Simplify paragraph path to reuse flushInlineToSection()
- Add tests: emoji in code spans, adjacent valid/invalid shortcodes,
  emoji in table cells, 101-row off-by-one boundary

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@navidemad
navidemad merged commit 7ae9033 into main Mar 6, 2026
3 checks passed
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.

1 participant