Skip to content

Commit

Permalink
Merge pull request #236 from noborus/escape-markdown
Browse files Browse the repository at this point in the history
Added escape processing
  • Loading branch information
noborus authored Sep 26, 2023
2 parents c478dcb + a4f5857 commit ba9f9c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions output_tablewriter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package trdsql

import (
"strings"

"github.com/olekukonko/tablewriter"
)

Expand All @@ -10,6 +12,7 @@ type TWWriter struct {
outNULL string
results []string
needNULL bool
markdown bool
}

// NewTWWriter returns TWWriter.
Expand All @@ -24,6 +27,7 @@ func NewTWWriter(writeOpts *WriteOpts, markdown bool) *TWWriter {
}
w.needNULL = writeOpts.OutNeedNULL
w.outNULL = writeOpts.OutNULL
w.markdown = markdown
return w
}

Expand All @@ -43,6 +47,9 @@ func (w *TWWriter) WriteRow(values []interface{}, columns []string) error {
str = w.outNULL
} else {
str = ValString(col)
if w.markdown {
str = strings.ReplaceAll(str, `|`, `\|`)
}
}
w.results[i] = str
}
Expand Down

0 comments on commit ba9f9c8

Please sign in to comment.