js-yaml icon indicating copy to clipboard operation
js-yaml copied to clipboard

Allow compact mode with indent !== 2

Open Congelli501 opened this issue 7 years ago • 2 comments

I like compact mode for arrays, but it is disabled if indent is !== 2

Cf this line of code: https://github.com/nodeca/js-yaml/blob/master/lib/js-yaml/dumper.js#L697

I'd like to have an output like this:

title:
    source: hello
    steps:
    -   step1
    -   name: step2
        attr: stepInfo

Instead of this:

title:
    source: hello
    steps:
        - step1
        -
            name: step2
            name: stepInfo

What do you think about this format ?

Congelli501 avatar Jun 07 '17 16:06 Congelli501

Is there a way to configure the 'compact' mode for arrays? In Version 3.14 I get

array:
  - object: 1
    name: O1
  - object: 2
    name: O2

but would like to get it like:

array:
  - 
    object: 1
    name: O1
  -
    object: 2
    name: O2

The first one throws errors in java eoyaml parser:

com.amihaiemil.eoyaml.exceptions.YamlIndentationException: Indentation of line 3 is greater than the one of line 2. It should be less or equal.

chriamue avatar Jun 11 '20 06:06 chriamue

Guys, is there an update on this? Any workaround?

rubenhak avatar Jul 30 '20 20:07 rubenhak