emoji

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 8 Imported by: 0

README

go-emoji

Build Status

Golang Emoji parser, converter to html and images

Usage

Parse
parser := NewEmojiParser()
var text = "a #💩 #and #🍦 #😳"
var i = -1
replased := parser.ReplaceAllStringFunc(text, func(s string) string {
	i++
	return strconv.Itoa(i)
})
// replased == "a #0 #and #1 #2"
Convert
To HTML-Entities
parser := NewEmojiParser()
text := "a #💩 #and #🍦 #😳"
replased := parser.ToHtmlEntities(text)
// replased == "a #💩 #and #🍦 #😳"
To HTML-Images
parser := NewEmojiParser()
text := "a #💩 #and #🍦 #😳"
replased := parser.ToHtmlImages(text)

result:

a #<img
class="emoji"
draggable="false"
alt="💩"
src="https://twemoji.maxcdn.com/36x36/1f4a9.png"> #and #<img
class="emoji"
draggable="false"
alt="🍦"
src="https://twemoji.maxcdn.com/36x36/1f366.png"> #<img
class="emoji"
draggable="false"
alt="😳"
src="https://twemoji.maxcdn.com/36x36/1f633.png">

References

  1. Instagram developers blog
  2. Twemoji SVG https://github.com/twitter/twemoji
  3. Unicode Emojii data emoji-data.txt
  4. Unicode Tech Report 51 tech report
  5. Contributors of the same library for the PHP https://github.com/urakozz/php-emoji-regex/pulls?q=is%3Apr+is%3Aclosed

Documentation

Overview

Package emoji contains emoji parser and modifiers Copyright 2015 Yury Kozyrev. Licence MIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEmojiParser

func NewEmojiParser() *emojiParser

NewEmojiParser creates a new parser loading emoji data from official Unicode definition

Types

type Details

type Details struct {
	Code           string //0
	Style          string //1
	Level          string //2
	ModifierStatus string //3
	Version        string
	Representation string
	Description    string //1
}

Details represents Emoji's details based on Unicode definition http://unicode.org/Public/emoji/1.0/emoji-data.txt

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL