1--- %YAML:1.0
2test: Single ending newline
3brief: >
4    A pipe character, followed by an indented
5    block of text is treated as a literal
6    block, in which newlines are preserved
7    throughout the block, including the final
8    newline.
9yaml: |
10    ---
11    this: |
12        Foo
13        Bar
14php: |
15    ['this' => "Foo\nBar\n"]
16---
17test: The '+' indicator
18brief: >
19    The '+' indicator says to keep newlines at the end of text
20    blocks.
21yaml: |
22    normal: |
23      extra new lines not kept
24
25    preserving: |+
26      extra new lines are kept
27
28
29    dummy: value
30php: |
31    [
32        'normal' => "extra new lines not kept\n",
33        'preserving' => "extra new lines are kept\n\n\n",
34        'dummy' => 'value'
35    ]
36---
37test: Three trailing newlines in literals
38brief: >
39    To give you more control over how space
40    is preserved in text blocks, YAML has
41    the keep '+' and chomp '-' indicators.
42    The keep indicator will preserve all
43    ending newlines, while the chomp indicator
44    will strip all ending newlines.
45yaml: |
46    clipped: |
47        This has one newline.
48
49
50
51    same as "clipped" above: "This has one newline.\n"
52
53    stripped: |-
54        This has no newline.
55
56
57
58    same as "stripped" above: "This has no newline."
59
60    kept: |+
61        This has four newlines.
62
63
64
65    same as "kept" above: "This has four newlines.\n\n\n\n"
66php: |
67    [
68      'clipped' => "This has one newline.\n",
69      'same as "clipped" above' => "This has one newline.\n",
70      'stripped' => 'This has no newline.',
71      'same as "stripped" above' => 'This has no newline.',
72      'kept' => "This has four newlines.\n\n\n\n",
73      'same as "kept" above' => "This has four newlines.\n\n\n\n"
74    ]
75---
76test: Extra trailing newlines with spaces
77todo: true
78brief: >
79    Normally, only a single newline is kept
80    from the end of a literal block, unless the
81    keep '+' character is used in combination
82    with the pipe.  The following example
83    will preserve all ending whitespace
84    since the last line of both literal blocks
85    contains spaces which extend past the indentation
86    level.
87yaml: |
88    ---
89    this: |
90        Foo
91
92
93    kept: |+
94        Foo
95
96
97php: |
98    ['this' => "Foo\n\n  \n",
99      'kept' => "Foo\n\n  \n"]
100
101---
102test: Folded Block in a Sequence
103brief: >
104    A greater-then character, followed by an indented
105    block of text is treated as a folded block, in
106    which lines of text separated by a single newline
107    are concatenated as a single line.
108yaml: |
109    ---
110    - apple
111    - banana
112    - >
113        can't you see
114        the beauty of yaml?
115        hmm
116    - dog
117php: |
118    [
119        'apple',
120        'banana',
121        "can't you see the beauty of yaml? hmm\n",
122        'dog'
123    ]
124---
125test: Folded Block as a Mapping Value
126brief: >
127    Both literal and folded blocks can be
128    used in collections, as values in a
129    sequence or a mapping.
130yaml: |
131    ---
132    quote: >
133        Mark McGwire's
134        year was crippled
135        by a knee injury.
136    source: espn
137php: |
138    [
139        'quote' => "Mark McGwire's year was crippled by a knee injury.\n",
140        'source' => 'espn'
141    ]
142---
143test: Three trailing newlines in folded blocks
144brief: >
145    The keep and chomp indicators can also
146    be applied to folded blocks.
147yaml: |
148    clipped: >
149        This has one newline.
150
151
152
153    same as "clipped" above: "This has one newline.\n"
154
155    stripped: >-
156        This has no newline.
157
158
159
160    same as "stripped" above: "This has no newline."
161
162    kept: >+
163        This has four newlines.
164
165
166
167    same as "kept" above: "This has four newlines.\n\n\n\n"
168php: |
169    [
170      'clipped' => "This has one newline.\n",
171      'same as "clipped" above' => "This has one newline.\n",
172      'stripped' => 'This has no newline.',
173      'same as "stripped" above' => 'This has no newline.',
174      'kept' => "This has four newlines.\n\n\n\n",
175      'same as "kept" above' => "This has four newlines.\n\n\n\n"
176    ]
177