• Stars
    star
    47
  • Rank 584,246 (Top 12 %)
  • Language
    Crystal
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ’š Emoji for Crystal

emoji.cr

Crystal CI

Emoji library for Crystal. Inspired by Emoji for Python

Installation

As a dependency in shard.yml:

dependencies:
  emoji:
    github: veelenga/emoji.cr
    branch: master

Usage

require "emoji"

puts Emoji.emojize("I :heart: :beer: and :football:")

Will print the following in console:

Also it is possible to remove all emoji from the string:

str = Emoji.emojize("Girl on :fire:")
Emoji.sanitize(str) #=> "Girl on "

Sanitizing is based on Emoji regex. There are two options available:

  • :simple emoji regex (default)
  • :generated emoji regex

Simple regex uses unicode ranges to find emojis and may give some incorrect results. Generated regex is quite big, but works correctly in 100% cases. However, it is much slower than a simple regex.

If you need more accuracy sanitizing emojis and don't care about performance, just use generated one:

Emoji.sanitize(str, regex: :generated)

Regex

require "emoji"

string = "String which contains all kinds of emoji:

- Singleton Emoji: (๐Ÿ’Ž)
- Textual singleton Emoji with Emoji variation: (โ–ถ๏ธ)
- Emoji with skin tone modifier: (๐Ÿ–๐Ÿผ)
- Region flag: (๐Ÿ‡บ๐Ÿ‡ฆ)
- Sub-Region flag: (๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ)
- Keycap sequence: (7๏ธโƒฃ)
- Sequence using ZWJ (zero width joiner): (๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ)

"

string.scan(Emoji::GENERATED_EMOJI_REGEX) do |m|
  puts "`#{m[0]}` - #{m[0].size} code points"
end
`๐Ÿ’Ž` - 1 code points
`โ–ถ๏ธ` - 2 code points
`๐Ÿ–๐Ÿผ` - 2 code points
`๐Ÿ‡บ๐Ÿ‡ฆ` - 2 code points
`๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ` - 7 code points
`7๏ธโƒฃ` - 3 code points
`๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ` - 7 code points

Binary

You may also compile and use emojize binary that just prints to console emojized string:

crystal build bin/emojize
./emojize It will boom: :boom:

Resources

Contributing

  1. Fork it ( https://github.com/veelenga/emoji.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

More Repositories

1

awesome-crystal

๐Ÿ’Ž A collection of awesome Crystal libraries, tools, frameworks and software
Crystal
3,307
star
2

dress

๐Ÿ‘— Dress up your stdout
Elixir
62
star
3

lua.cr

Crystal to Lua bridge
Crystal
59
star
4

carbon-now-sh.el

Emacs to https://carbon.now.sh integration
Emacs Lisp
56
star
5

aasm.cr

๐Ÿ”ƒ Easy to use finite state machine for Crystal classes
Crystal
50
star
6

vicr

โœŒ๏ธ Vim-like Interactive CRystal
Crystal
41
star
7

i3ipc-ruby

๐Ÿ›ซ An improved Ruby library to control i3wm
Ruby
35
star
8

crystal-zsh

.oh-my-zsh plugin for Crystal
Shell
28
star
9

aws-lambda-face-blur

AWS Lambda Face Blur
JavaScript
17
star
10

aws-heic-converter

AWS Lamba HEIC Converter
JavaScript
13
star
11

shorturl.cr

A tiny library to use URL shortening services
Crystal
13
star
12

rainbow-spec

Rainbow spec formatter for Crystal
Crystal
12
star
13

rblist

Russia Ban List
TypeScript
11
star
14

yymmdd

โณ Simple DSL for working with dates.
Crystal
9
star
15

wil

What I Learnt
Ruby
8
star
16

terminal-focus-reporting.el

Minor mode for terminal focus reporting
Emacs Lisp
7
star
17

ember-mail-to

Ember component to create HTML mailto links
JavaScript
6
star
18

play-crystal.el

Emacs to https://play.crystal-lang.org integration
Emacs Lisp
6
star
19

jsonapi-payload-explorer

JSON::API Payload Explorer
JavaScript
6
star
20

bojack.ex

Elixir client for BoJack - the unreliable key-value store ๐Ÿด
Elixir
5
star
21

aws-dynamodb.cr

Crystal client for AWS DynamoDB
Crystal
5
star
22

jira_report

๐Ÿ“Ž Cli tool that prints jira activity report.
Ruby
4
star
23

nyancat.ex

Nyancat for Elixir ๐Ÿฑ
Elixir
4
star
24

gh-pr-review-voodoo

A GitHub bot to improve PR review workflow.
TypeScript
3
star
25

crystal-snippets

YASnippet Crystal snippets for Emacs
Emacs Lisp
3
star
26

raph

Ruby Argument Parsing for Humans
Ruby
2
star
27

heroku-buildpack-sidekiq.cr

Sidekiq for Crystal Heroku Buildpack
Shell
2
star
28

curly.el

Straight way to work with current file locations in Emacs
Emacs Lisp
2
star
29

aws-lambda-blur-by-rekognition-label

AWS Lambda to blur objects detected by AWS Rekognition
JavaScript
1
star
30

homebrew-tap

Ruby
1
star
31

veelenga.github.io

My own blog pages
CSS
1
star
32

cybfootball

ะคัƒั‚ะฑะพะปัŒะฝั– ั‚ัƒั€ะฝั–ั€ะธ ั„ะฐะบัƒะปัŒั‚ะตั‚ัƒ ะบั–ะฑะตั€ะฝะตั‚ะธะบะธ
Ruby
1
star
33

libcurl.cr

Crystal bindings to libcurl [WIP]
Crystal
1
star
34

crown

Preview markdown files locally with Crystal Markdown
Crystal
1
star
35

any_setting

Load your settings with ease
Crystal
1
star
36

ee

exercism exercises
Elixir
1
star
37

hallo

I tiny project for Make your own Shard in Crystal language tutorial
Crystal
1
star
38

ctci

Solutions for Cracking the Coding Interview, 5th edition
Crystal
1
star
39

react-flash-messages

Rails flash messages with React
Ruby
1
star
40

rev.ex

Use reveal.js in your Elixir ๐Ÿšง
Elixir
1
star
41

dotfiles

Storing my dotfiles
Emacs Lisp
1
star
42

kyiv-coworking-map

Kyiv Coworking Map
HTML
1
star