2020-11-27 19:40:24 +01:00
|
|
|
package display
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Indent prepends each line of a string with a tab
|
|
|
|
func Indent(str string) string {
|
2020-11-28 17:18:16 +01:00
|
|
|
|
|
|
|
// trim superfluous whitespace
|
|
|
|
str = strings.TrimSpace(str)
|
|
|
|
|
|
|
|
// prepend each line with a tab character
|
2020-11-27 19:40:24 +01:00
|
|
|
out := ""
|
|
|
|
for _, line := range strings.Split(str, "\n") {
|
|
|
|
out += fmt.Sprintf("\t%s\n", line)
|
|
|
|
}
|
|
|
|
|
2020-11-28 17:18:16 +01:00
|
|
|
return out
|
2020-11-27 19:40:24 +01:00
|
|
|
}
|