ini-parser icon indicating copy to clipboard operation
ini-parser copied to clipboard

Proposal: Allow supression of empty lines before Section

Open glatzert opened this issue 8 years ago • 5 comments

Allow the programmer to set something like "NewLineBeforeNextSection" in the Parser.Configuration. Some INI Readers don't like the empty lines there

glatzert avatar Nov 25 '16 08:11 glatzert

I don't really understand the issue. You mean that blank lines before a section confuses an INI reader? Which reader, do you have an example?

rickyah avatar Dec 05 '16 23:12 rickyah

I have a Blackbox-Software which will accept an INI file in a specific location. Whatever that parser inside the (proprietary) software is - it will stop processing files upon the first empty line. Yes, I know that parser sucks, no I cannot do anything about it.

But if I just load and write a file without modifications, the ini-parser (yours), which does a pretty good job, will not result in the same file, since \r\n will be added before Sections (or probably at the end of sections). So I use a MemoryStream to write the Ini-Data, write that to an string, make replace operations in the string (\r\n\r\n --> \r\n) and finally write the string to the hdd. And thus I proposed a setting.

glatzert avatar Dec 06 '16 07:12 glatzert

I'm planning a rewrite of the parser so it is easy to tackle this kind of things, and more (comments in the same line) but it will take a little bit of time

rickyah avatar Feb 17 '17 11:02 rickyah

Nice 👍 If you are up-for-grabs, I'd possibly able to spare some time into the Parser as well (since it is a valuable tool for me, that'd be more than fair :))

glatzert avatar Feb 17 '17 11:02 glatzert

It would also be nice to be able to disable the new line before comments on key-value pairs as well. https://github.com/rickyah/ini-parser/blob/260b764ea7ed0039eadb90d383e40b76287bb0ea/src/IniFileParser/Model/Formatting/IniDataFormatter.cs#L63

csnewman avatar May 24 '18 15:05 csnewman