Skip to content

Commit 4774c63

Browse files
authored
fix: Tag stripping in plain mode (#839)
1 parent 63b9b0d commit 4774c63

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/view/helper.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io"
66
"os"
7+
"regexp"
78
"strings"
89
"text/tabwriter"
910
"time"
@@ -154,7 +155,7 @@ func renderPlain(w io.Writer, data tui.TableData) error {
154155
for _, items := range data {
155156
n := len(items)
156157
for j, v := range items {
157-
_, _ = fmt.Fprintf(w, "%s", v)
158+
_, _ = fmt.Fprintf(w, "%s", unescape(v))
158159
if j != n-1 {
159160
_, _ = fmt.Fprintf(w, "\t")
160161
}
@@ -168,6 +169,11 @@ func renderPlain(w io.Writer, data tui.TableData) error {
168169
return nil
169170
}
170171

172+
func unescape(s string) string {
173+
pattern := regexp.MustCompile(`(\[[a-zA-Z0-9_,;: \-\."#]+\[*)\[\]`)
174+
return pattern.ReplaceAllString(s, "$1]")
175+
}
176+
171177
func coloredOut(msg string, clr color.Attribute, attrs ...color.Attribute) string {
172178
c := color.New(clr).Add(attrs...)
173179
return c.Sprint(msg)

0 commit comments

Comments
 (0)