func JoinRule(rule string) string {
split := strings.Split(rule, `" "`)
joined := strings.Join(split, "|")
- joined = joined
return joined
}
var start string
var end string
// Use m and s flags by default
- flags := "ms"
if len(submatch) == 5 {
// If len is 5 the user provided some additional flags
color = string(submatch[1])
- flags += string(submatch[2])
start = string(submatch[3])
end = string(submatch[4])
} else if len(submatch) == 4 {
output := ""
output += fmt.Sprintf("filetype: %s\n\n", filetype)
- output += fmt.Sprintf("detect: \n filename: \"%s\"\n", strings.Replace(syntax, "\\", "\\\\", -1))
+ output += fmt.Sprintf("detect: \n filename: \"%s\"\n", strings.Replace(strings.Replace(syntax, "\\", "\\\\", -1), "\"", "\\\"", -1))
if header != "" {
- output += fmt.Sprintf(" header: \"%s\"\n", strings.Replace(header, "\\", "\\\\", -1))
+ output += fmt.Sprintf(" header: \"%s\"\n", strings.Replace(strings.Replace(header, "\\", "\\\\", -1), "\"", "\\\"", -1))
}
output += "\nrules:\n"