Download Latest Version v1.1.0 source code.tar.gz (97.4 kB)
Email in envelope

Get an email when there's a new version of Lip Gloss

Home / v1.1.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2025-03-13 4.4 kB
v1.1.0 source code.tar.gz 2025-03-13 97.4 kB
v1.1.0 source code.zip 2025-03-13 147.5 kB
Totals: 3 Items   249.3 kB 1

Tables, Improved

In this release, the @andreynering and @bashbunni majorly overhauled on the table sizing and content wrapping behavior. Tables will now be much smarter on deciding the ideal width of each column, and content will now wrap by default inside cells.

If you don't want content to wrap, set .Wrap(false), and the content will be cut with an ellipsis (), a behavior the was not properly working correctly before (content would just be cut, even middle word).

:::go
// Table content wraps by default.
t := table.New().
    Headers(someHeaders...).
    Rows(someRows...).
    Width(80)

fmt.Println(t)

:::go
// Actually, let's not wrap the content.
t := table.New().
    Headers(someHeaders...).
    Rows(someRows...).
    Width(80).
    Wrap(false)

fmt.Println(t)

New Border Styles

Also, we added two new border styles that you can use to generate tables in Markdown and ASCII styles.

Markdown Tables

To render tables correctly for Markdown you'll want to use lipgloss.MarkdownBorder and disable the top and bottom borders.

:::go
t := table.New().
    Headers(someHeaders...).
    Rows(someRows).
    Border(lipgloss.MarkdownBorder()).
    BorderTop(false).
    BorderBottom(false)

fmt.Println(t)

ASCII Tables

To render an ASCII-style table use lipgloss.ASCIIBorder.

:::go
t := table.New().
    Headers(someHeaders...).
    Rows(someRows).
    Border(lipgloss.ASCIIBorder())

fmt.Println(t)

Thanks everyone

Special thanks to @aymanbagabas @bashbunni and @andreynering or all the work on this release!


Changelog

New Features

  • 7862f5293d37c466f48d7a5f8520305257b9356f: feat(table): improve sizing and behavior: wrap by default, overflow optionally (@andreynering)
  • 1f1209e8be34adf156ed35bed6aded58410f071b: feat(table): use cellbuf to preserve styles for wrapped content (@bashbunni)
  • c454a0adaafcf9ff18704e8b27aa8fe4a2d22026: feat(tables): add markdown and ascii border style for tables (#480) (@andreynering)
  • bafb8fd00083f5f8f25badf85e19cae9162d8ce0: feat(tree): hide children (#460) (@bashbunni)
  • 99421664af19e293501170dc3971acf569e9cead: feat: style ranges (#458) (@caarlos0)

Bug fixes

  • 9500f10a6b9145b4d3ed9b317ad952ca162dbde3: fix(table): ensure we're passing the right row index to styleFunc (@andreynering)
  • 7b191c57d42d0bb7e73873719ad5d572aced14ec: fix(test): make table wrapping tests use golden files (@bashbunni)
  • 9b8304fa373da3258031a13e2ad19b0d1ec264eb: fix: border size getters when implicit borders are present (#411) (@meowgorithm)
  • 022e96717265bb4650a770f5abf2b3c5fcc85e58: fix: range test (@caarlos0)

Other work

  • ecc1bd014d511a81d0f46628c9c177f299231d6a: fix: comment on min func in utils (@derezzolution)
  • 5cd2074b01fe997f9ce16189dbe39680c11f96d0: style(table): improve naming of the resizer functions (@andreynering)
  • 9cfb7dd7998c648cbe502b96bac83ddb8ca2a38c: test(table): check truncation logic for overflow and nowrap (@bashbunni)
  • 2aa2eb0349ddb873dcd4548a642cc3b3e6809d90: test(table): test wrapping cell styles (@bashbunni)
  • ca67d0fd5d54e4b171c3c1867e6e00d82e34183d: chore(lint): apply De Morgans law to the if statement (@aymanbagabas)
  • 0fbb0700f064a7b7b2821b20e35e8d2fd5add307: chore(lint): fix lint ignore comments (@andreynering)

The Charm logo

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

Source: README.md, updated 2025-03-13