Skip to content

feat: emoji shortcodes as an optional inline pass (./inline/emoji) - #91

Merged
jonathanKingston merged 1 commit into
mainfrom
claude/emoji-shortcodes
Jul 8, 2026
Merged

feat: emoji shortcodes as an optional inline pass (./inline/emoji)#91
jonathanKingston merged 1 commit into
mainfrom
claude/emoji-shortcodes

Conversation

@jonathanKingston

Copy link
Copy Markdown
Collaborator

Closes #86.

Promotes the EXTENDING.md emoji recipe to a shipped, optional inline pass behind @copse/streaming-markdown/inline/emoji — off by default, zero bytes in the main bundle unless imported (asserted in-test by bundling index.ts with esbuild and checking a glyph is absent).

What's in here

  • src/emoji-shortcodes.tsemojiInlinePass, createEmojiInlinePass(map?) factory, re-exported emojiShortcodes map. Built purely on the public setInlinePasses contract — no core registry added (unlike highlight/mermaid/katex).
  • src/emoji-shortcode-map.ts — 1913 gemoji aliases → emoji, generated from github/gemoji, living only in the lazy module (~50 KB on that chunk, never the main bundle).
  • Obeys the inline-pass contract: fires only outside <code>/<a>/<img>, respects \:smile:, unknown shortcodes pass through literally, holdStart prevents mid-stream :smi flash.

API decisions

  • Stage before-links so emoji render inside link labels ([go :rocket:](url)).
  • Factory + exposed mapcreateEmojiInlinePass(customMap) for host extension; emojiShortcodes re-exported for inspection.
  • Prototype-pollution guard — lookups go through a Map built from the object, so :constructor: / :tostring: (valid shortcode shape, inherited keys) stay literal instead of emitting [object …] / function source.
  • Hold refinementholdStart exempts a bare trailing colon so prose like Steps: / Note: never flickers; it only holds when ≥1 shortcode char follows (:smi). Consequence: a trailing :word run at EOL transiently holds until the next token — same self-resolving transient as the existing citation/strikethrough passes; no effect at rest.

Verification

  • npm run typecheck, npm run build (dist/emoji-shortcodes.* emitted) — pass
  • npm test — 785 tests, 783 pass, 0 fail, 2 skip (incl. 17 emoji tests + the bundle-isolation assertion)
  • npm run check:conformance / npm run check:gfm-conformance — 2/2
  • npm run coverage:ci — 99.79% (baseline ratcheted up from 99.75)

Caveats

  • The gemoji table was regenerated deterministically from gemoji master; a maintainer refresh script could follow but wasn't in scope.
  • One overlapping-load run showed unrelated CPU-contention flakes (a Shiki timing test, a throughput floor) — neither touches emoji; isolated run is green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ehmok4AzyTQDNkRzW3g8z8


Generated by Claude Code

Promote the EXTENDING.md emoji recipe (#86) to a shipped, optional inline
pass behind the `@copse/streaming-markdown/inline/emoji` subpath. It maps
`:shortcode:` to emoji via a GitHub/gemoji-aligned table (1913 aliases) so
`:shortcode:`s an LLM emits resolve to the glyph GitHub would render.

Built entirely on the public `setInlinePasses` contract, so it needs no
core registry and adds zero bytes to the main bundle unless imported (an
esbuild bundle assertion pins this). The pass obeys the full inline-pass
contract for free: `` `:smile:` `` and `\:smile:` stay literal, unknown
codes pass through, and a `holdStart` suppresses a half-typed `:smi` mid
stream. `createEmojiInlinePass(map)` lets a host extend/replace the table;
lookups go through a Map to close a prototype-pollution hole
(`:constructor:` stays literal).

Docs: EXTENDING.md inline-pass section now points at the built-in pass,
plus a LAZY-LOADING.md subsection and a README mention. Coverage ratchet
raised 99.75% -> 99.79%.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ehmok4AzyTQDNkRzW3g8z8
@jonathanKingston
jonathanKingston merged commit 3cc6f73 into main Jul 8, 2026
1 check 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.

Emoji shortcodes (:smile:) as an optional inline pass

2 participants