mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-19 14:44:18 +02:00
Trim unstyled padding spaces from output
This commit is contained in:
parent
aa9ca8ab1e
commit
fa9d64c4ef
1 changed files with 16 additions and 2 deletions
18
main.go
18
main.go
|
|
@ -9,6 +9,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -138,8 +139,21 @@ func execute(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
out, err := r.RenderBytes(b)
|
||||
fmt.Printf("%s", string(out))
|
||||
return err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lines := strings.Split(string(out), "\n")
|
||||
for i, s := range lines {
|
||||
fmt.Print(strings.TrimSpace(s))
|
||||
|
||||
// don't add an artifical newline after the last split
|
||||
if i+1 < len(lines) {
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue