Documentation
¶
Overview ¶
Package mention provides function for parsing twitter like mentions and hashtags
Index ¶
- func DecodeUTF16ToString(s []uint16) string
- func EncodeStringToUTF16(s string) []uint16
- func EncodeStringToUTF16Index(s string) []int
- func GetTagsAsUniqueStrings(prefix rune, str string, terminator ...rune) (strs []string)
- func GetTagsAsUniqueUTF16Strings(prefix rune, str []uint16, terminator ...rune) (strs [][]uint16)
- type Tag
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeUTF16ToString ¶
func EncodeStringToUTF16 ¶
func EncodeStringToUTF16Index ¶
Encode returns the UTF-16 encoding of the Unicode code point sequence s.
func GetTagsAsUniqueStrings ¶
GetTagsAsUniqueStrings gets all tags as a slice of unique strings. This is here to have a means of being somewhat backwards compatible with previous versions of mention
func GetTagsAsUniqueUTF16Strings ¶
GetTagsAsUniqueStrings gets all tags as a slice of unique strings. This is here to have a means of being somewhat backwards compatible with previous versions of mention
Types ¶
type Tag ¶
type Tag struct { // The character used to mark the beginning of the tag. Char rune // Tag non space string that follows after the tag character mark. Tag string // Tag non space string that follows after the tag character mark. TagUTF16 []uint16 // Index is the byte position in the source string where the tag was found. Index int }
Tag is string that is prefixed with a marker. Often used to mark users like @genrest.
func GetTags ¶
GetTags returns a slice of Tags, that is all characters after rune char up to occurrence of space or another occurrence of rune char. Additionally you can provide a coma separated unicode characters to be used as terminating sequence.
Example (Hashtag) ¶
msg := " viva la #tanzania" tags := GetTagsAsUniqueStrings('#', msg) fmt.Println(tags)
Output: [tanzania]
Example (Mention) ¶
msg := " hello @gernest" tags := GetTagsAsUniqueStrings('@', msg) fmt.Println(tags)
Output: [gernest]