Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 21f23e6

Browse filesBrowse files
committed
YAML mutli-line literal: emit block indentiation indicator
When dumping YAML: When the first line of a multi-line string literal starts with a space, emit a block indentation indicator. As per spec at: http://www.yaml.org/spec/1.2/spec.html#id2793979 Issue #26065
1 parent ba22f0c commit 21f23e6
Copy full SHA for 21f23e6

File tree

1 file changed

+4
-1
lines changed
Filter options

1 file changed

+4
-1
lines changed

‎src/Symfony/Component/Yaml/Dumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Dumper.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ public function dump($input, $inline = 0, $indent = 0, $flags = 0)
9898

9999
foreach ($input as $key => $value) {
100100
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) {
101-
$output .= sprintf("%s%s%s |\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '');
101+
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
102+
// http://www.yaml.org/spec/1.2/spec.html#id2793979
103+
$blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : '';
104+
$output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator);
102105

103106
foreach (preg_split('/\n|\r\n/', $value) as $row) {
104107
$output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.