Closed whatsdis closed 9 years ago
---
2:
2a: "test"
Correctly produces:
{ '2': { '2a': 'test' } }
Also, I tried your example app with multiple (complex) yaml files and it looks good. What's the problem? :)
Ooops... there must be some issue with your program, example link you gave me: when I open the page initially it shows wrong results, but when I edit anything and revert back to original I got correct results (?)
screenshot:
really strange. I think the option indentWithTab
is causing this problem, yet ironically without that turned on, I get lint errors with YAML.
and this happens on and off.
Please see this http://stackoverflow.com/questions/32929402/yaml-why-isnt-this-creating-a-subobject
@whatsdis looks like you should convert tabs to spaces internally before sending yaml to the parser. In that case your users will be able to use tabs and everything will be converted as expected.
btw, is this issue with codemirror? what you got when you read text from codemirror? does it gives you mixed spaces and tabs?
Btw, I just packaged codemirror for meteor - so, I'm not expert for codemirror at all.
hum.. maybe this helps: there is option indent size or similar (I'm writing from mobile phone). This option is 2 by default, but when you use tabs, thi is still 2, so maybe you got 2 tabs instead one and maybe that is the problem ( just guessing)
seems like this is what it is
indentUnit: integer How many spaces a block (whatever that means in the edited language) should be indented. The default is 2. smartIndent: boolean Whether to use the context-sensitive indentation that the mode provides (or just indent the same as the line before). Defaults to true. tabSize: integer The width of a tab character. Defaults to 4. indentWithTabs: boolean Whether, when indenting, the first N*tabSize spaces should be replaced by N tabs. Default is false.
well this is what it's doing
"test:\n\t child: asdf\n\t subchild:\n\t\t path: //a\t\n\t"
yeah actually this isn't your issue, it's codemirror's. They have a bug for this exact issue and nobody seems to give a crap enough to fix it.
I'll try out your idea with replacing tabs with spaces just before firing it off
thanks again Petar! that worked beautifully.
with
indentWithTabs
option on or off, it doesn't matter but now it's running into parsing issues with the YAML. for instance, it will not detect anything deeper than the first level, if you create a field with another indentation to illustrate that this is an object with many fields.example yaml:
t: 1: "test" 2: 2a: "test"
results in via js yaml
http://nodeca.github.io/js-yaml/#yaml=dDoKCTE6ICJ0ZXN0IgoJMjogCgkJMmE6ICJ0ZXN0Ig==
as you can see I expected {2:{2a:"test"}, }
Sometimes when I refresh the page, it will work. Other times it won't, so I don't know what's going on.