π emoji β Emoji β text for Starlark

emoji is an L4 domain module of the Star* ecosystem. The ecosystem's
remit is support for necessary local operations plus simple abstractions
over common online services, for ease of use β and emoji sits squarely on
the local side: it is a pure, offline text utility. There is no network, no
service, and no credentials; at run time the module reads only embedded Go maps
and does pure Unicode arithmetic, so it has zero third-party data dependencies.
Overview
It converts between text and emoji two ways:
- Shortcodes β
:rocket: β π, driven by a generated data table that merges
several actively-maintained upstream datasets (see Data).
- Look-alikes β turn a plain number, clock time, letter, or punctuation mark
into the most similar emoji:
42 β 4οΈβ£2οΈβ£, 3:30 β π, AB β π¦π§, !? β ββ.
For the complete per-builtin reference β signatures, parameters, returns,
errors, examples β and the configuration accessors, see
docs/API.md.
Installation
go get github.com/starpkg/emoji
Quick start
Wire the module into a Starlet interpreter, then load("emoji", β¦) from a
script:
package main
import (
"fmt"
"github.com/1set/starlet"
"github.com/starpkg/emoji"
)
func main() {
mod := emoji.NewModule()
interpreter := starlet.NewWithLoaders(nil, nil, starlet.ModuleLoaderMap{
"emoji": mod.LoadModule(),
})
script := `
load("emoji", "emojize")
out = emojize("ship it :rocket::tada:")
`
if _, err := interpreter.RunScript([]byte(script), nil); err != nil {
fmt.Println(err)
}
}
From Starlark:
load("emoji", "emojize", "demojize", "convert", "number_to_emoji", "time_to_emoji")
emojize("i :heart: starlark :rocket:") # i β€οΈ starlark π
demojize("i β€οΈ starlark π") # i :heart: starlark :rocket:
number_to_emoji(2026) # 2οΈβ£0οΈβ£2οΈβ£6οΈβ£
time_to_emoji("9:15") # π€ (rounded to 9:30)
convert("AB", kind="letter") # π¦π§
convert(":fire:") # π₯ (auto-detected emojize)
Starlark API at a glance
Top-level builtins (load("emoji", β¦)). Shortcode group (backed by the data
table):
emojize(text) β replace every known :shortcode: with its emoji glyph.
demojize(text, delimiters?) β the inverse; replace glyphs with :shortcodes:.
get(name) β emoji glyph for a single shortcode, or None.
name(emoji) β canonical shortcode for a single glyph, or None.
describe(emoji) β human-readable name for a single glyph, or None.
Look-alike group (pure Unicode arithmetic):
number_to_emoji(value, keycap_ten?) β digits β keycap emoji.
emoji_to_number(text) β the inverse; keycap emoji β digits.
time_to_emoji(value, minute?) β a time β the nearest clock-face emoji.
letter_to_emoji(text, style?) β letters β regional / squared / circled emoji.
symbol_to_emoji(text) β punctuation ! ? # * + - / Γ Γ· β symbol emoji.
Dispatcher and metadata:
convert(value, kind?) β dispatch to a conversion family (default kind="auto").
info() β a dict describing the embedded dataset.
See docs/API.md for the full signatures, return values,
errors, and examples of every builtin above.
Configuration
The module's single option, max_input_bytes, bounds the input size of text
conversions. It is configured via the EMOJI_MAX_INPUT_BYTES environment
variable or the generated get_max_input_bytes / set_max_input_bytes accessor
builtins. See the
Configuration section of docs/API.md for the full
option table, default, and accessors.
Data
The shortcode table is not a runtime dependency on any single (and possibly
stale) emoji library. It is generated, offline, by merging pinned datasets from
different language ecosystems into one Go table:
| Source |
Ecosystem |
Pinned |
Role |
| carpedm20/emoji |
Python |
v2.15.0 |
Spine: the freshest, fullest shortcode set (Emoji 17.0), aliases, names. |
| github/gemoji |
Ruby |
v4.1.0 |
GitHub's canonical :shortcodes: (:smile:, :+1:) + tidy descriptions. |
internal/gen reads the vendored JSON, applies gemoji first (so its well-known
short aliases win) then carpedm20 (which fills the gaps and the newest emoji),
and writes tables_gen.go. Output is deterministic β sorted, ASCII-escaped, no
timestamps β so refreshing the data is a reviewable diff, not a black box.
See data/SOURCES.md for provenance and licenses.
License
This project is licensed under the MIT License β see LICENSE.
The vendored datasets keep their upstream licenses (carpedm20/emoji: BSD-3-Clause;
github/gemoji: MIT). Only text data (names, shortcodes, code points) is used β no
image assets. Attribution and license texts are in
data/SOURCES.md.