libyaml
libyaml copied to clipboard
Indentation of sequence elements
In the current version (0.2.5) the emitter does not indent sequence elements for the block sequence style, e.g.:
foo:
- hello
- world
While correct, it is way harder to read than the more conventional representation where sequence elements are indented:
foo:
- hello
- world
This is quite noticeable in large documents with lots of deeply nested values.
Would it be possible to add an option to support this kind of output ?
Looking at the repository, I am not sure who is in charge of coordinating development for libyaml, so any pointer is welcome :) I may be able to provide a patch if someone can provide a minimum of guidance and is ok with merging it and releasing a new version.
A lot of libraries in various languages rely on libyaml, this would help lots of people !
foo: - hello - world
I actually prefer this representation and use it across all YAML files I write manually.
Anyone ? Is libyaml even maintained ?
@galdor I too would really appreciate the ability to be able to output sequences with this style of indentation. Perhaps @perlpunk @ingydotnet could advise on a way to proceed and provide code review/merging/version bump when appropriate
I'd like this feature to be implemented, too. I can think of three different ways we might want to do that:
- Simply indent sequences by the user-configured indent, i.e. set by
yaml_emitter_set_indent
. - Add a flag to the aforementioned function to enable/disable sequence indentation, e.g, something like:
yaml_emitter_set_indent(yaml_emitter_t* emitter, int indent, int indent_block_sequences)
. - Maybe add a flag to the function
yaml_sequence_start_event_initialize()
, like above?
Any maintainer input here? I understand this is probably a lower priority item than some other issues.
I agree that many huge yaml files with nested values would be easy to read if the emitter produce sequences with indentation.