Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/winter. a thoughtful static website generator for long-lasting content twos.dev/winter
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940package cliutils // import "twos.dev/winter/cliutils"
import ( "fmt" "strings"
markdown "github.com/MichaelMure/go-term-markdown" "github.com/lithammer/dedent")
// Printf is like [fmt.Printf],// but applies several visual treatments to make format pleasant to read at a terminal,// especially when it spans multiple lines or paragraphs.//// Specifically,// single newlines and common indentation are ignored// and the text is wrapped to 80 characters// (allowing strings to be well-formatted in both source code and output),// and limited Markdown support is applied.func Printf(format string, args ...any) (int, error) { return fmt.Print(Sprintf(format, args...))}
// Sprintf is like [fmt.Sprintf],// but applies visual treatments for pleasant reading at a terminal,// especially when it spans multiple lines or paragraphs.//// Specifically,// single newlines and common indentation are ignored// and the text is wrapped to 80 characters// (allowing strings to be well-formatted in both source code and output),// and limited Markdown support is applied.func Sprintf(format string, args ...any) string { format = fmt.Sprintf(format, args...) format = dedent.Dedent(format) format = strings.TrimSpace(format) format = string(markdown.Render(format, 80, 0)) return format}