Skip to content

How to control indents via param options to dump? #468

Closed

Description

@diberry

An extra 2 spaces is getting added on the item "C#" and its href. How do I turn this off?

original yaml:

`

Final yaml where last 2 lines have additional (but unwanted) 2 spaces:

`

yaml-indent

Activity

  1. puzrin commented on Feb 18, 2019

    @puzrin
    Member
  2. diberry commented on Feb 18, 2019

    @diberry
    ContributorAuthor

    Here are all my options, I toggled noArrayIndent and the results are in the screenshot. Left = original

    options={ "skipInvalid":false, "noCompatMode":false, "sortKeys":false, "lineWidth":3000, "noArrayIndent":false, "noRefs":true, "flowLevel":-1, "condenseFlow":false }

    no-array-index-results

  3. puzrin commented on Feb 18, 2019

    @puzrin
    Member

    Is this this a question or not? Is this issue solved?

  4. perlpunk commented on Feb 18, 2019

    @perlpunk

    @diberry could you paste your results as text instead of a screenshot? just put three backticks in one line
    before and after the pasted snippet. or indent the whle snippet with 4 spaces. makes it easier to copy snippets and try them out.

    @puzrin it looks like a bug to me. in the picture on the right the YAML seems invalid. items like href: ... in line 2 and expanded: ... in line 4 have no indent

  5. diberry commented on Feb 18, 2019

    @diberry
    ContributorAuthor

    @perlpunk Thanks for the pointer.
    @puzrin I think it is a bug - it I'm not as strict with Yaml as this library so I don't know if it is the library as a bug, the the library as intended behavior.

    original

    - name: LUIS Documentation
      href: index.yml
    - name: Overview
      expanded: true
      items:
      - name: C#
        href: https://cognitive.uservoice.com/knowledgebase/topics/asdfasdfasdfasdfasdfasdf/127872-luis-language-understanding-intelligent-service
    

    "noArrayIndent"= false

    - name: LUIS Documentation
      href: index.yml
    - name: Overview
      expanded: true
      items:
        - name: 'C#'
          href: 'https://cognitive.uservoice.com/knowledgebase/topics/asdfasdfasdfasdfasdfasdf/127872-luis-language-understanding-intelligent-service'
    

    "noArrayIndent"=true

    - name: LUIS Documentation
    href: index.yml
    - name: Overview
    expanded: true
    items:
    - name: 'C#'
      href: 'https://cognitive.uservoice.com/knowledgebase/topics/asdfasdfasdfasdfasdfasdf/127872-luis-language-understanding-intelligent-service'
    

    What I would like but not sure how to get it from .dump() - notice the same indent spacing as original.

    - name: LUIS Documentation
      href: index.yml
    - name: Overview
      expanded: true
      items:
      - name: 'C#'
        'href: https://cognitive.uservoice.com/knowledgebase/topics/asdfasdfasdfasdfasdfasdf/127872-luis-language-understanding-intelligent-service'
    
  6. puzrin commented on Feb 18, 2019

    @puzrin
    Member

    That's certainly a bug, need fix. I've asked PR author. Or anyone else can do new PR.

    Seems happen when root is array (rare case, missed)

  7. diberry commented on Feb 18, 2019

    @diberry
    ContributorAuthor

    @puzrin I would like to fix and PR.

  8. puzrin commented on Feb 18, 2019

    @puzrin
    Member

    No problem. https://github.com/nodeca/js-yaml/pull/461/files - use this as example. If implementation will be correct, i'll approve & release asap.

  9. added a commit that references this issue on Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions