Skip to content

Repository files navigation

hygge/golor

workflowGo Report CardGo Reference

Turns github.com/fatih/color into HTML. Just kidding!

It is just a very convenient way of dealing with colors in the terminal to get some fancy output.

Just a tag based approach to write some nice text, supporting text/template.

Usage

From simple

golor.Println(`This is a #red[part of text with #bold[some] in bold] word.Possible to #(blue,italic)[combine]`)

simple

To more interesting

golor.Println(`#(blue)[Welcome to #(red)[hygge-io/golor]!]#(green,italic)[{{.FromTemplate}} in italic]#(cyan,bold)[<some brackets> in bold]{{- range .Items}}#(yellow,bold)[{{.}}]{{end}}Notice the #(white,bold,italic)[trick] to not have lines between the range items!`, map[string]any{
"FromTemplate": "Hello from template",
"Items": []string{"Item 1", "Item 2"},
})
}

output

Changing the syntax for the style tags!

Depending on the text you want to format, it can be necessary to change how the parsing is done:

s:=`In Markdown, @(bold)<a new paragraph> uses the # tagwhile links are written as @green<[link](url)>`renderer:=golor.New().WithTagMarker('@').WithTextLimiter('<', '>')
fmt.Println(renderer.Render(s))

output

About

Turns github.com/fatih/color into HTML. Just kidding!

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages