yaml-cpp
yaml-cpp copied to clipboard
Maximum width on YAML::Flow layout
Hi. As of now I've followed the tutorial and read some docs. I have a question/feature-request:
- Is there a way to limit width of emitter so that it automatically do line wrapping in Flow layout in case it gets too long?
For example, for the following YAML:
foo: [
a, b, c,
d, e, f
]
Emitting it through the API I get:
foo: [a, b, c, d, e, f]
The problem is when the sequence is quite long, I'd like to get some output like the former one, not too wide nor too tall.
This is a very old bug, but I also think it would be great to have this feature. If I understand correctly, pyYaml supports setting a line width: https://dpinte.wordpress.com/2008/10/31/pyaml-dump-option/
@jbeder Your thoughts on this? I have a similar case where I would like the lines to wrap after a certain length, similar to this example: https://github.com/zeldamods/oead/blob/master/test/byml/files/A-1_Dynamic.yml
It seems that both rapidyaml and pyaml have this behavior, but yaml-cpp does not support line wrapping.
Sure, but I'm not sure how we'd get the output in the first example because it seems to know the entirety of the sequence, whereas the yaml-cpp API is streaming. But in principle yes.
Makes sense. For my case, it would not necessarily have to be in the format of the first comment. Simple line wrapping would be fine for me. Something like:
- '!Parameters': {DropTable: Normal, InitMotionStatus: 0, IsEnemyLiftable: true, IsPlayerPut: false,
SharpWeaponJudgeType: 0}
How difficult would such a change be? If you have some code pointers, I'd be happy to take a shot at it.