Parsing of Python multiline configparser ini dialect
Python's configparser allows to parse these multiline sections and will have a value of `'\nb\nc'` for `foo`:
```
[section1]
foo =
b
c
[section2]
bar = 1
```
I would like to parse this as well with `rust-ini`. However currently this fully **ignores** `section2` and leads to this:
```
Properties {
data: {
"foo": "",
"b\n c\n[section2]\nbar": "1",
},
}
```
In my opinion this is very weird and should probably never be the case. Here it seems that the key becomes something very long that even "eats" the next section. At the very least I feel like this should not be a valid key. I personally would like to change the current behavior to parse these multiline inis. Would a PR be accepted? I'm happy to do the work. Otherwise I would probably just fork. Do you think we need a feature flag for this like `multiline-values`? I feel like the current behavior doesn't really help anybody either.
If someone is interested, this is how you do it in Python:
```
>>> s = '''
... [section1]
... foo =
... b
... c
... [section2]
... bar = 1
... '''
>>> import configparser
>>> c = configparser.ConfigParser()
>>> c.read_string(s)
>>> c.items("section1")
[('foo', '\nb\nc')]
>>> c.items("section2")
[('bar', '1')]
```
关闭于 2024-11-05 3 条评论