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

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

Closed
diberry opened this issue Feb 18, 2019 · 8 comments
Closed

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

diberry opened this issue Feb 18, 2019 · 8 comments
Labels

Comments

@diberry
Copy link
Contributor

diberry commented Feb 18, 2019

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

@puzrin
Copy link
Member

puzrin commented Feb 18, 2019

@diberry
Copy link
Contributor Author

diberry commented Feb 18, 2019

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

@puzrin
Copy link
Member

puzrin commented Feb 18, 2019

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

@perlpunk
Copy link

@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

@diberry
Copy link
Contributor Author

diberry commented Feb 18, 2019

@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'

@puzrin
Copy link
Member

puzrin commented Feb 18, 2019

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)

@puzrin puzrin added the bug label Feb 18, 2019
@diberry
Copy link
Contributor Author

diberry commented Feb 18, 2019

@puzrin I would like to fix and PR.

@puzrin
Copy link
Member

puzrin commented Feb 18, 2019

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.

This was referenced Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants