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

Support for multiline values

Open jark-b90 opened this issue 5 years ago • 6 comments

Hello,

Is there any chance to have support for multiline values in some future versions?

[section1] key1 = "this key is on multiple rows"

jark-b90 avatar Feb 21 '20 14:02 jark-b90

It's a good idea...

AkioSarkiz avatar Mar 05 '20 02:03 AkioSarkiz

Yep, very interested in this. We have some legacy INIs that older systems could handle the multi-line value. Now were having issues because we can't parse them with this new library. Other than this, the library is awesome!

JerseyTechGuy avatar Jun 05 '20 15:06 JerseyTechGuy

Anyone know how to do this in C#? I have to change a ini file which the value is

key1 = loltest
yepyepxd

and i'm breaking my head trying to do this

SrMilton avatar May 06 '21 05:05 SrMilton

@SrMilton Were you able to do it? If so, it would be interesting to see your solution.

DevD4v3 avatar Dec 05 '21 15:12 DevD4v3

@MrDave1999 No. I was using a technique with read all lines, changing what i need and write all lines back. It's a really bad way to do this but i have no other idea.

SrMilton avatar Dec 05 '21 16:12 SrMilton

So I did something very, very hacky... but maybe this will be useful for others.

So my problem is that I'm parsing a .pylintrc file. The attached implementation is a one-way conversion from multiline values to singleline values. This is utilising the fact that the multiline values in this format, are in fact an array of comma separated values where the last non-whitespace character conveniently is a comma. An example of such is

value = foo,
        bar

When rewriting the file, it's stored as

value = foo,bar

One would have to rewrite this slightly to cover the initial use case that @johnFA90 outlines. What @SrMilton is outlining however, is quite a level more complex to cover I think. You'd basically have to fetch following lines to find the next valid start of something. Probably a fun little adventure to fix...or maybe not so fun...

Anyway, hope this file is helpful for others. multiline_parser.txt

AHSauge avatar Jan 12 '22 18:01 AHSauge