# README
PACKAGE STYLE
text
provides text manipulation functions (like indentation, wrapping,
columnize,...) that can differentiate printable from non-printable sequences
(like ANSI colored sequences).
text
provides helpers to format tables and to print diff between text.
EXAMPLE
package main
import (
"fmt"
"github.com/pirmd/text"
"github.com/pirmd/text/ansi"
)
func Example() {
tab := text.NewTable().SetMaxWidth(80).SetGrid(" ", "-", " ")
tab.Rows(
[]string{"Column1", "Column2", "Column3"},
[]string{"Basic column", "This one is here\nto demonstrate\nthat colums with several lines work too", "Any " + ansi.SetBold("formatted") + " string can be inserted too without beaking the table."},
[]string{"", "This second row is here to test multi-lines rows format", "Also possibly a second chance to verify that multi-lines is working"},
)
fmt.Println(tab.Draw())
}
INSTALLATION
Everything should work fine using go standard commands (build
, get
,
install
...).
USAGE
Running go doc github.com/pirmd/text
should give you helpful guidelines on
available features.
CONTRIBUTION
If you feel like to contribute, just follow github guidelines on forking then send a pull request
# Functions
Center centers text and pads it with spaces to reach the given "visual" length.
Columnize organizes supplied strings in a side-by-side fashion.
Indent inserts a name/bullet/number at the beginning of the string, then indents it (add prefix at the beginning and before any new line).
Justify wraps a text to the given maximum size and makes sure that returned lines are of exact provided size by wrapping and padding them as needed.
LazyTab wraps and indents the given text.
LazyWrap wraps a text by ensuring that each of its line's "visual" length is lower or equal to the provided limit.
Left aligns text on the left and pads it with spaces to reach the given "visual" length.
Right aligns text on the right and pads it with spaces to reach the given "visual" length.
Rowwise organizes supplied strings in a table-like fashion.
Tab wraps and indents the given text.
Tabulate organizes supplied string in a table-like fashion.
Wrap wraps a text by ensuring that each of its line's "visual" length is lower or equal to the provided limit.