emojipasta

package module
v0.0.0-...-a1b72e3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 8 Imported by: 0

README

emojipasta

emojipasta is a minimal library that can generate emojipasta from the given text.

This is the library which powers emozi.

Go Reference

Installation

go get github.com/Shravan-1908/emozi/emojipasta

Usage

package main

import (
	"fmt"
	"github.com/Shravan-1908/emozi/emojipasta"
)

func main() {
	generator := emojipasta.New().WithDefaultMappings()
	// you can also set your custom mappings
	// generator := emojipasta.New().WithCustomMappings(myCustomMapping)

	// the default max emojis per block is set to 2
	// you can change it as following
	err := generator.SetMaxEmojisPerBlock(3)
	if err != nil {
		...
	}
	fmt.Println(generator.GenerateEmojiPasta("I just hope this works. No tests are available sorry."))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator holds the emoji mappings and the number of max emojis per block.

func New

func New() *Generator

Returns a pointer to a Generator struct with maxEmojisPerBlock set to 2.

func (*Generator) GenerateEmojiPasta

func (epg *Generator) GenerateEmojiPasta(text string) string

Generates the emoji pasta from the given text.

func (*Generator) SetMaxEmojisPerBlock

func (epg *Generator) SetMaxEmojisPerBlock(n int) error

Sets Generator.maxEmojisPerBlock to the given number. Returns an error is the given number is negative.

func (*Generator) WithCustomMappings

func (epg *Generator) WithCustomMappings(customMapping map[string][]string) *Generator

Sets Generator.mappings to the given custom mappings. Example of a custom mapping is {"hi": ["✋", "👋"], "person": ["👦", "🧔"]...}

func (*Generator) WithDefaultMappings

func (epg *Generator) WithDefaultMappings() *Generator

Sets Generator.mappings to the default emoji mappings.

Jump to

Keyboard shortcuts

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