Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion configparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,32 @@ broken_option = this value will miss
c.Assert(result, DeepEquals, configparser.Dict{
"testing": "multiline\nvalue",
"myoption": "another\nmultiline\nvalue",
"broken_option": "this value will miss",
"broken_option": "this value will miss\n\nits multiline",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to change to will not miss?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot can you address this feedback?

})
}

// TestNewlineValueParsing tests parsing values that are on a new line after the key,
// including cases with empty lines between key and value.
func (s *ConfigParserSuite) TestNewlineValueParsing(c *C) {
parsed, err := configparser.ParseReader(
strings.NewReader(`[section]
option1 = value1
option2 = value2
option3 =
value3
option4 =

value4
`),
)
c.Assert(err, IsNil)
result, err := parsed.Items("section")
c.Assert(err, IsNil)
c.Assert(result, DeepEquals, configparser.Dict{
"option1": "value1",
"option2": "value2",
"option3": "value3", // Value on next line
"option4": "value4", // Value after empty line
})
}

Expand Down
1 change: 1 addition & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func defaultOptions() *options {
delimiters: ":=",
commentPrefixes: Prefixes{"#", ";"},
multilinePrefixes: Prefixes{"\t", " "},
emptyLines: true, // Allow empty lines in multiline values by default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this change should also lead to deprecation of the AllowEmptyLines, since this option will be ON by default and introduction of NoEmptyLines or something similar to bring back old behavior?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emar-kar Thanks for the reminder about this - I gave this task to Copilot to figure it out and then forgot about it😄

converters: Converter{
StringConv: defaultGet,
IntConv: defaultGetInt64,
Expand Down