Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Ben-Kiki O.YAML ain't markup language.V1.1.pdf
Скачиваний:
7
Добавлен:
23.08.2013
Размер:
1.06 Mб
Скачать
[154] nb-plain-char-out ::=

Syntax

4.5.1.3. Plain

The plain style uses no identifying indicators, and is therefore the most most limited and most context sensitive scalar style. Plain scalars can never contain any tab characters. They also must not contain the “: ” and “ #” character sequences as these combinations cause ambiguity with key: value pairs and comments. Inside flow collections, plain scalars are further restricted to avoid containing the “[”, “]”, “{”, “}” and “,” characters as these would cause ambiguity with the flow collection structure (hence the need for the flow-in context and the flow-out context).

[153] nb-plain-char(c) ::= c

= flow-out

Þ nb-plain-char-out

c

= flow-in

Þ nb-plain-char-in

c

= flow-key

Þ nb-plain-char-in

( nb-char - “:” - “#” - #x9 /*TAB*/ ) | ( ns-plain-char(flow-out) “#” )

| ( “:” ns-plain-char(flow-out) )

[155]nb-plain-char-in ::= nb-plain-char-out - “,” - “[” - “]” - “{” - “}”

[156]ns-plain-char(c) ::= nb-plain-char(c) - #x20 /*SP*/

The first plain character is further restricted to avoid most indicators as these would cause ambiguity with various YAML structures. However, the first character may be “-”, “?” or “:” provided it is followed by a non-space character.

[157] ns-plain-first-char(c) ::=

(

ns-plain-char(c) - c-indicator )

 

| (

( “-” | “?” | “:” ) ns-plain-char(c) )

Example 4.63. Plain Characters

# Outside flow collection:

- :: std::vector

- U p , up and away!

- -1 23

# Inside flow collection:

-[ :: std::vector, "Up , up and away!", -1 23 ]

Legend:

ns-plain-first-char(c)

ns-plain-char(c)Not ns-plain-char(c)

%YAML 1.1

---

!!seq [

!!str "::std::vector", !!str "Up, up and away!", !!int "-123",

!!seq [

!!str "::std::vector", !!str "Up, up and away!", !!int "-123",

]

]

Plain scalars are restricted to a single line when contained inside a simple key.

[158] ns-plain(n,c) ::= c

= flow-out

Þ ns-plain-multi(n,c)?

c

= flow-in

Þ ns-plain-multi(n,c)?

c

= flow-key

Þ ns-plain-single(c)

57

XSLFO

RenderX

Syntax

Example 4.64. Plain Scalars

simple key : {

also simple : value,

? not a

simple key : any

value

}

Legend:

ns-plain-single(c)ns-plain-multi(n,c)

%YAML 1.1

---

!!map {

? !!str "simple key"

:!!map {

?!!str "also simple" : !!str "value",

?!!str "not a simple key" : !!str "any value"

}

}

The first line of any flow scalar is indented according to the collection it is contained in. Therefore, there are two cases where a plain scalar begins on the first column of a line, without any preceding indentation spaces: a plain scalar used as a simple key of a non-indented block mapping, and any plain scalar nested in a non-indented flow collection. In these cases, the first line of the plain scalar must not conflict with a document boundary marker.

[159] l-forbidden-content ::= /*

start

of

line */

( c-document-start | c-document-end )

/*

space

or

end of line */

Example 4.65. Forbidden Non-Indented Plain Scalar Content

---

---· ||| : foo

...· >>>: bar

---

[

---

,

...· ,

{

---· :

...· # Nested

}

]

...

ERROR:

The --- and ... document start and end markers must not be specified as the first content line of a non-indented plain scalar.

58

XSLFO

RenderX

Syntax

YAML provides several easy ways to present such content without conflicting with the document boundary markers. For example:

Example 4.66. Document Marker Scalar Content

---

" --- " : foo ... : bar

---

[

--- ,

... ,

{

? --- : ...

}

]

...

Legend:

Content --- and ...

Document marker --- and ...

%YAML 1.1

---

!!map {

?!!str "---" : !!str "foo",

?!!str "...", : !!str "bar"

}

%YAML 1.1

---

!!seq [

!!str "---", !!str "...", !!map {

? !!str "---" : !!str "..."

}

]

Thus, a single line plain scalar is a sequence of valid plain non-break printable characters, beginning and ending with nonspace character and not conflicting with a document boundary markers. All characters are considered content, including any inner space characters.

[160] ns-plain-single(c) ::=

( ns-plain-first-char(c)

 

( nb-plain-char(c)* ns-plain-char(c) )? )

- l-forbidden-content

In a multi-line plain scalar, line breaks are subject to (flow) line folding. Any prefix and trailing spaces are excluded from the content. Like single quoted scalars, in plain scalars it is impossible to force the inclusion of the leading or trailing spaces in the content. Therefore, plain scalars lines can only be broken where a single space character separates two nonspace characters.

[161] s-l-plain-break(n) ::= s-ignored-white* b-l-folded-any(n,plain)

59

XSLFO

RenderX

Соседние файлы в предмете Электротехника