Properly escape start and end regexes

This commit is contained in:
Zachary Yedidia
2017-03-21 14:48:24 -04:00
parent 523f75654d
commit fa7f89a400

View File

@@ -148,8 +148,8 @@ func generateFile(filetype, syntax, header string, rules []interface{}) string {
output += fmt.Sprintf(" - %s: \"%s\"\n", rule.color, strings.Replace(strings.Replace(rule.regex, "\\", "\\\\", -1), "\"", "\\\"", -1))
} else if rule, ok := r.(MultiRule); ok {
output += fmt.Sprintf(" - %s:\n", rule.color)
output += fmt.Sprintf(" start: \"%s\"\n", rule.start)
output += fmt.Sprintf(" end: \"%s\"\n", rule.end)
output += fmt.Sprintf(" start: \"%s\"\n", strings.Replace(strings.Replace(rule.start, "\\", "\\\\", -1), "\"", "\\\"", -1))
output += fmt.Sprintf(" end: \"%s\"\n", strings.Replace(strings.Replace(rule.end, "\\", "\\\\", -1), "\"", "\\\"", -1))
output += fmt.Sprintf(" rules: []\n\n")
}
}