Skip to content

Commit

Permalink
cli: escape as basic strings by default
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed May 11, 2022
1 parent f7ad71d commit 525c9c1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cmd/tomledit/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/creachadair/command"
"github.com/creachadair/tomledit"
"github.com/creachadair/tomledit/parser"
"github.com/creachadair/tomledit/scanner"
"github.com/creachadair/tomledit/transform"
)

Expand Down Expand Up @@ -186,12 +187,7 @@ func hasPrefixIn(needle parser.Key, keys []parser.Key) bool {

func parseValue(s string) (parser.Value, error) {
if strings.HasPrefix(s, "@") {
var actual string
if strings.Contains(s, "\n") {
actual = `'''` + s[1:] + `'''`
} else {
actual = `'` + s[1:] + `'`
}
actual := `"` + string(scanner.Escape(s[1:])) + `"`
return parser.ParseValue(actual)
}
return parser.ParseValue(s)
Expand Down

0 comments on commit 525c9c1

Please sign in to comment.