Skip to content

Emitting styles (and removing extra new lines) #29

@leoetlino

Description

@leoetlino

Is it possible to configure the emitting style (block/flow and newlines)?

Currently, I have a bunch of existing YAML documents that look like this:

enemy:
- actors:
  - {name: Enemy_Bokoblin_Junior, value: 4.0} 
  - {name: Enemy_Bokoblin_Middle, value: 16.0} 
  - {name: Enemy_Bokoblin_Senior, value: 32.0} 
  - {name: Enemy_Bokoblin_Dark, value: 48.0} 
  species: BokoblinSeries 
# ...

Nice and readable, with the flow (inline) style being used for simple maps that don't contain nested maps (which is the PyYAML default).

Emitting the same document with ryml currently results in the following:

enemy:
  -
    actors:
      -
        name: Enemy_Bokoblin_Junior
        value: 4
      -
        name: Enemy_Bokoblin_Middle
        value: 16
      -
        name: Enemy_Bokoblin_Senior
        value: 32
      -
        name: Enemy_Bokoblin_Dark
        value: 48
    species: BokoblinSeries

which isn't that bad but it's comparatively harder to read and it's also a bit too long.

So to get back to the questions:

  • Is it possible to get rid of the new line that is emitted for maps that are sequence items? For some reason, this only affects maps that are sequence items.

  • Does ryml make it possible to set the flow style (block/inline) for maps and sequences? I was unable to find any such functionality in the API but it's possible I've missed something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions