8000 [Yaml] Allow comments after tab by superdav42 · Pull Request #15747 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Yaml] Allow comments after tab #15747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Prev Previous commit
Next Next commit
[Yaml] Allow tabs before comments at the end of a line
Yaml 1.2 space white space is space or tab
  • Loading branch information
superdav42 committed Sep 14, 2015
commit c32d06da155e915b2c6755e3897d1a54a3a2dafe
3 changes: 2 additions & 1 deletion src/Symfony/Component/Yaml/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter
$i += strlen($output);

// remove comments
if (false !== $strpos = strpos($output, ' #')) {
if ((false !== $strpos = strpos($output, '#')) &&
($output[$strpos-1] == ' ' || $output[$strpos-1] == "\t")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be on one line

$output = rtrim(substr($output, 0, $strpos));
}
} elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ yaml: |
ex2: "foo # bar" # comment
ex3: 'foo # bar' # comment
ex4: foo # comment
ex5: foo # comment with tab before
php: |
array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo')
array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo', 'ex5' => 'foo')
---
test: Comments in the middle
brief: >
Expand Down
0