Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indentation of sequence elements #224

Open
galdor opened this issue Sep 10, 2021 · 5 comments
Open

Indentation of sequence elements #224

galdor opened this issue Sep 10, 2021 · 5 comments

Comments

@galdor
Copy link

galdor commented Sep 10, 2021

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 !

@i-ky
Copy link

i-ky commented Sep 10, 2021

foo:
- hello
- world

I actually prefer this representation and use it across all YAML files I write manually.

@galdor
Copy link
Author

galdor commented Sep 22, 2021

Anyone ? Is libyaml even maintained ?

@samrjenkins
Copy link

@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

@AmateurECE
Copy link

AmateurECE commented Feb 5, 2022

I'd like this feature to be implemented, too. I can think of three different ways we might want to do that:

  1. Simply indent sequences by the user-configured indent, i.e. set by yaml_emitter_set_indent.
  2. 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).
  3. 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.

@ziyangc97
Copy link

I agree that many huge yaml files with nested values would be easy to read if the emitter produce sequences with indentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants