mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 08:35:42 +00:00
Escape larger set of characters in Lua output
Started with a minimum of replacements, this should be more complete, tho not all substitutions are strictly required in Lua.
This commit is contained in:
parent
07b53fca7d
commit
21c64fa945
@ -18,7 +18,44 @@ func (le *luaEncoder) CanHandleAliases() bool {
|
||||
}
|
||||
|
||||
func NewLuaEncoder() Encoder {
|
||||
escape := strings.NewReplacer("\n", "\\n", "\"", "\\\"", "\\", "\\\\")
|
||||
escape := strings.NewReplacer(
|
||||
"\000", "\\000",
|
||||
"\001", "\\001",
|
||||
"\002", "\\002",
|
||||
"\003", "\\003",
|
||||
"\004", "\\004",
|
||||
"\005", "\\005",
|
||||
"\006", "\\006",
|
||||
"\007", "\\a",
|
||||
"\010", "\\b",
|
||||
"\011", "\\t",
|
||||
"\012", "\\n",
|
||||
"\013", "\\v",
|
||||
"\014", "\\f",
|
||||
"\015", "\\r",
|
||||
"\016", "\\014",
|
||||
"\017", "\\015",
|
||||
"\020", "\\016",
|
||||
"\021", "\\017",
|
||||
"\022", "\\018",
|
||||
"\023", "\\019",
|
||||
"\024", "\\020",
|
||||
"\025", "\\021",
|
||||
"\026", "\\022",
|
||||
"\027", "\\023",
|
||||
"\030", "\\024",
|
||||
"\031", "\\025",
|
||||
"\032", "\\026",
|
||||
"\033", "\\027",
|
||||
"\034", "\\028",
|
||||
"\035", "\\029",
|
||||
"\036", "\\030",
|
||||
"\037", "\\031",
|
||||
"\"", "\\\"",
|
||||
"'", "\\'",
|
||||
"\\", "\\\\",
|
||||
"\177", "\\127",
|
||||
)
|
||||
return &luaEncoder{"return ", ";\n", escape}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user