diff --git a/internal.go b/internal.go index 2223523..12eedec 100644 --- a/internal.go +++ b/internal.go @@ -358,6 +358,25 @@ func renderLine(line iniLine) string { } } +func renderKeyValue(line iniLine) string { + separator := line.separator + if separator == "" { + separator = defaultSeparator + } + return line.indent + line.keyName + separator + formatValue(line.keyValue) +} + +func formatValue(value string) string { + if strings.TrimSpace(value) == value && !hasSurroundingQuotes(value) { + return value + } + quote := `"` + if strings.HasPrefix(value, `"`) && strings.HasSuffix(value, `"`) { + quote = "`" + } + return quote + value + quote +} + func (ini *GoINI) formatString() string { formattedLines := make([]string, 0, len(ini.fileLines)) pendingComments := make([]string, 0) @@ -393,25 +412,6 @@ func formatINIComment(comment string) string { return "# " + comment } -func renderKeyValue(line iniLine) string { - separator := line.separator - if separator == "" { - separator = defaultSeparator - } - return line.indent + line.keyName + separator + formatValue(line.keyValue) -} - -func formatValue(value string) string { - if strings.TrimSpace(value) == value && !hasSurroundingQuotes(value) { - return value - } - quote := `"` - if strings.HasPrefix(value, `"`) && strings.HasSuffix(value, `"`) { - quote = "`" - } - return quote + value + quote -} - func matchStrings(items []string, match string) []string { if match == "" { return cloneStrings(items)