Page MenuHomeMusing Studio

tags.go
No OneTemporary

package category
import (
"strings"
"unicode"
)
// titleFromHashtag generates an all-lowercase title, with spaces inserted based on initial capitalization -- e.g.
// "MyWordyTag" becomes "my wordy tag".
func titleFromHashtag(hashtag string) string {
var t strings.Builder
var prev rune
for i, c := range hashtag {
if unicode.IsUpper(c) {
if i > 0 && !unicode.IsUpper(prev) {
// Insert space if previous rune wasn't also uppercase (e.g. an abbreviation)
t.WriteRune(' ')
}
t.WriteRune(unicode.ToLower(c))
} else {
t.WriteRune(c)
}
prev = c
}
return t.String()
}

File Metadata

Mime Type
text/plain
Expires
Tue, Feb 10, 8:46 PM (10 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3622813

Event Timeline