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

Syntax

4.4.3. Node Content

Node content may be presented in either a flow style or a block style. Block content always extends to the end of a line and uses indentation to denote structure, while flow content starts and ends at some non-space character within a line and uses indicators to denote structure. Each collection kind can be presented in a single flow collection style or a single block collection style. However, each collection kind also provides compact in-line forms for common cases. Scalar content may be presented in the plain style or one of the two quoted styles (the single quoted style and the double quoted style). Regardless of style, scalar content must always be indented by at least one space. In contrast, collection content need not be indented (note that the indentation of the first flow scalar line is determined by the block collection it is nested in, if any).

[114] ns-flow-scalar(n,c) ::=

c-plain(max(n,1),c)

 

| c-single-quoted(max(n,1),c)

 

| c-double-quoted(max(n,1),c)

[115]c-flow-collection(n,c) ::= c-flow-sequence(n,c) | c-flow-mapping(n,c)

[116]ns-flow-content(n,c) ::= ns-flow-scalar(n,c) | c-flow-collection(n,c)

[117]c-l+block-scalar(n) ::= c-l+folded(max(n,0)) | c-l+literal(max(n,0))

[118]c-l-block-collection(n,c) ::= c-l-block-sequence(n,c) | c-l-block-mapping(n)

[119] c-l+block-content(n,c) ::=

c-l+block-scalar(n)

 

| c-l-block-collection(>n,c)

Example 4.44. Mandatory Scalar Indentation

---

%YAML 1.1

foo:

---

· "bar

!!map {

· baz"

? !!str "foo"

: !!str "bar baz"

---

}

"foo

%YAML 1.1

· bar"

---

---

!!str "foo bar"

foo

%YAML 1.1

 

· bar

---

--- |

!!str "foo bar"

· foo

%YAML 1.1

...

---

 

!!str "foo bar\n"

Legend:

Normal "more-indented" indentation

Mandatory for "non-indented" scalar

47

XSLFO

RenderX

Syntax

Example 4.45. Flow Content

---

scalars:

plain: !!str some text quoted:

single: 'some text' double: "some text"

collections:

sequence: !!seq [ !str entry,

# Mapping entry: key: value ]

mapping: { key: value }

Legend:

ns-flow-scalar

c-flow-collection

not content

%YAML 1.1

--- !!map {

?!!str "scalars" : !!map {

?!!str "plain"

:!!str "some text", ? !!str "quoted"

:!!map {

? !!str "single"

:!!str "some text", ? !!str "double"

:!!str "some text"

} },

?!!str "collections": : !!map { ? !!str "sequence" : !!seq [

? !!str "entry",

: !!map {

? !!str "key" : !!str "value"

}],

?!!str "mapping": : !!map {

? !!str "key" : !!str "value"

}} }

Example 4.46. Block Content

block styles: scalars:

literal: !!str |

#!/usr/bin/perl

print "Hello, world!\n"; folded: >

This sentence

is false. collections: !!seq

sequence: !!seq # Entry: - entry

# Mapping entry: - key: value

mapping: key: value

Legend:

c-l+block-scalar

c-l-block-collection

not content

%YAML 1.1

---

!!map {

?!!str "block styles" : !!map { ? !!str "scalars" : !!map {

? !!str "literal"

: !!str "#!!/usr/bin/perl\n\ print \"Hello, world!!\\n\";\n",

? !!str "folded"

: !!str "This sentence is false.\n"

},

?!!str "collections" : !!map {

?!!str "sequence" : !!seq [ !!str "entry",

!!map {

?!!str "key" : !!str "value"

}

],

?!!str "mapping" : !!map {

? !!str "key" : !!str "value"

}} } }

48

XSLFO

RenderX

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