Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is tab valid in key/value pair in YAML parser?

Tags:

syntax

yaml

t: test

Pay attention that it's a tab after :,and I used this YAML parser to test whether it's valid or not(IMO it's not valid):

Array
(
    [t] => test
)
like image 837
user198729 Avatar asked Feb 15 '10 12:02

user198729


People also ask

Is tab allowed in YAML?

A YAML file use spaces as indentation, you can use 2 or 4 spaces for indentation, but no tab. In other words, tab indentation is forbidden: Why does YAML forbid tabs? Tabs have been outlawed since they are treated differently by different editors and tools.

How do I fix indentation error in YAML?

The error text states this is an indentation error, and you fix it by adding an additional two spaces before each dash ( - ) character. If you don't know why those are errors, read my YAML for Ansible article.

How do you write a key value pair in YAML?

Key-Value Pairs. The YAML above defines four keys - first_name , last_name , age_years , and home - with their four respective values. Values can be character strings, numeric (integer, floating point, or scientific representation), Boolean ( true or false ), or more complex nested types (see below).

How do I delete a tab in YAML?

Tab adds indentation, Shift+Tab removes indentation. You don't need to do that. Yaml doesn't care. Just leave the spaces in.


1 Answers

According to the specification, both tab (U+0009) and space (U+0020) are considered “white space characters” that may be used to delimit tokens.

So what makes you think it's illegal in that context? Especially considering that example 6.3 makes it clear that it's valid:

Example 6.3. Separation Spaces

-·foo:→·bar
- -·baz
  -→baz 

(· denotes a space (U+0020), while denotes a tab character (U+0009)).

like image 123
Joey Avatar answered Oct 17 '22 20:10

Joey