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

Unexpected indent #292

Closed
ysmood opened this issue Jun 17, 2016 · 2 comments
Closed

Unexpected indent #292

ysmood opened this issue Jun 17, 2016 · 2 comments

Comments

@ysmood
Copy link

ysmood commented Jun 17, 2016

var yaml = require('js-yaml');

yaml.load('|2\n  a\n  b'); // => ' a\n b\n'

It will output a\n b\n. It should output a\nb\n.

@dervus dervus added the bug label Jun 17, 2016
@puzrin puzrin mentioned this issue Feb 28, 2017
9 tasks
@eemeli
Copy link

eemeli commented Jan 27, 2019

Actually, this is not a bug but intended behaviour. The top level of a YAML document is considered to be at the -1 level so that e.g. |\na\nb\n doesn't cause an error but is parsed as 'a\nb\n'. Therefore if a top-level scalar block header includes a number, it should be one more than the expected number of indentation spaces.

This behaviour also matches that of other libraries:

import YAML from 'yaml'

YAML.parse('|2\n  a\n  b') // => ' a\n b\n'

@puzrin
Copy link
Member

puzrin commented Jan 28, 2019

Close as not a bug

@puzrin puzrin closed this as completed Jan 28, 2019
@puzrin puzrin added not a bug and removed bug labels Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants