Skip to content

v0.10.0

Latest
Compare
Choose a tag to compare
@maaslalani maaslalani released this 05 Mar 15:57
· 21 commits to master since this release
v0.10.0
439c06f

String Transforms ๐Ÿ’„

Lip Gloss v0.10.0 features a brand new Transform function for Styles to alter strings at render time. As well as some bug fixes, like ANSI-aware table cell truncation. ๐Ÿงน

Simply define a Transform function as func (string) string and apply it to any style:

// Example:
s := NewStyle().Transform(strings.ToUpper)
fmt.Println(s.Render("raow!") // "RAOW!"

Or, if you prefer:

// Example:
reverse := func(s string) string {
    n := 0
    rune := make([]rune, len(s))
    for _, r := range s {
        rune[n] = r
	n++
    }
    rune = rune[0:n]
    for i := 0; i < n/2; i++ {
        rune[i], rune[n-1-i] = rune[n-1-i], rune[i]
    }
    return string(rune)
}

s := NewStyle().Transform(reverse)
fmt.Println(s.Render("The quick brown ็‹ jumped over the lazy ็Šฌ")
// "็Šฌ yzal eht revo depmuj ็‹ nworb kciuq ehT",

What's Changed?

New Contributors

Full Changelog: v0.9.1...v0.10.0


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Slack.