mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 16:55:40 +00:00
Make output of unquoted Lua table keys optional
Generally safer and simpler to not do it.
This commit is contained in:
parent
c8919f20da
commit
cabb73b12c
@ -10,6 +10,7 @@ import (
|
|||||||
type luaEncoder struct {
|
type luaEncoder struct {
|
||||||
docPrefix string
|
docPrefix string
|
||||||
docSuffix string
|
docSuffix string
|
||||||
|
unquoted bool
|
||||||
escape *strings.Replacer
|
escape *strings.Replacer
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ func NewLuaEncoder() Encoder {
|
|||||||
"\\", "\\\\",
|
"\\", "\\\\",
|
||||||
"\177", "\\127",
|
"\177", "\\127",
|
||||||
)
|
)
|
||||||
return &luaEncoder{"return ", ";\n", escape}
|
return &luaEncoder{"return ", ";\n", false, escape}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (le *luaEncoder) PrintDocumentSeparator(writer io.Writer) error {
|
func (le *luaEncoder) PrintDocumentSeparator(writer io.Writer) error {
|
||||||
@ -131,7 +132,7 @@ func (le *luaEncoder) encodeMap(writer io.Writer, node *yaml.Node) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if child.Tag == "!!str" && !needsQuoting(child.Value) {
|
} else if le.unquoted && child.Tag == "!!str" && !needsQuoting(child.Value) {
|
||||||
err = writeString(writer, child.Value+"=")
|
err = writeString(writer, child.Value+"=")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user