From 273c5e61b71fbfce936f0a5395029a0abbf3254b Mon Sep 17 00:00:00 2001 From: headkaze Date: Thu, 10 Nov 2022 22:14:46 -0500 Subject: [PATCH] add NoMultiLineSurroundingQuotes option --- file.go | 2 +- ini.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/file.go b/file.go index f8b2240..032cbe8 100644 --- a/file.go +++ b/file.go @@ -460,7 +460,7 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { } // In case key value contains "\n", "`", "\"", "#" or ";" - if strings.ContainsAny(val, "\n`") { + if !f.options.NoMultiLineSurroundingQuotes && strings.ContainsAny(val, "\n`") { val = `"""` + val + `"""` } else if !f.options.IgnoreInlineComment && strings.ContainsAny(val, "#;") { val = "`" + val + "`" diff --git a/ini.go b/ini.go index 99e7f86..13c0ec6 100644 --- a/ini.go +++ b/ini.go @@ -115,6 +115,8 @@ type LoadOptions struct { KeyValueDelimiterOnWrite string // ChildSectionDelimiter is the delimiter that is used to separate child sections. By default, it is ".". ChildSectionDelimiter string + // NoMultiLineSurroundingQuotes indicates whether to add surrounding triple quotes to multi-line values. + NoMultiLineSurroundingQuotes bool // PreserveSurroundedQuote indicates whether to preserve surrounded quote (single and double quotes). PreserveSurroundedQuote bool // DebugFunc is called to collect debug information (currently only useful to debug parsing Python-style multiline values).