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

Comments

Projects
None yet
3 participants
@diberry
Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Feb 18, 2019

@diberry

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Member

commented Feb 18, 2019

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

@perlpunk

This comment has been minimized.

Copy link

commented Feb 18, 2019

@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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor Author

commented Feb 18, 2019

@puzrin I would like to fix and PR.

@puzrin

This comment has been minimized.

Copy link
Member

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.

diberry added a commit to diberry/js-yaml that referenced this issue Feb 24, 2019

puzrin added a commit that referenced this issue Feb 26, 2019

@puzrin puzrin closed this Feb 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.