1
0
mirror of https://github.com/Rudi9719/kbtui.git synced 2026-03-22 09:57:24 +00:00

added notes

This commit is contained in:
2019-10-20 15:53:40 -06:00
parent 0ba2507891
commit b0ea0c0b63

View File

@ -6,6 +6,8 @@ import (
"strings"
)
// this is a global var set by flag that indicates whether emoji shortnames should be reprinted as unicode emojis
// some systems may support this
var UNICODE_EMOJI_SUPPORT bool = false
type emojiData struct {
@ -15,7 +17,9 @@ type emojiData struct {
Alias []string
}
// this converts shortname emojis to unicode emojis when they can be found in the data map
func emojiUnicodeConvert(s string) string {
// currently fails to find newlines and replace them needs fixed
pStr := strings.Fields(s)
reeMatch := regexp.MustCompile(`:\w+:`)
for i, word := range pStr {
@ -32,6 +36,8 @@ func emojiUnicodeConvert(s string) string {
return strings.Join(pStr, " ")
}
// this resolves emoji aliases back to the root emoji that actually renders to a picture
// for example `:cheeseburger:` => `:hamburger:`
func resolveRootEmojis(s string) string {
pStr := strings.Fields(s)
reMatch := regexp.MustCompile(`:\w+:`)
@ -46,6 +52,7 @@ func resolveRootEmojis(s string) string {
return strings.Join(pStr, " ")
}
// this is the actual internal function that parses the unicode data to a unicode string representing the emoji
func renderUnicodeEmoji(data emojiData) (string, error) {
emj, err := strconv.ParseInt(data.Unicode, 16, 32)
if err != nil {