Skip to content

Commit 81bb295

Browse files
committed
Fix trimming of padding in table cells
This trims Unicode spaces (as done upstream) without removing newlines produces by escape sequences.
1 parent ec034ab commit 81bb295

File tree

3 files changed

+5
-58
lines changed

3 files changed

+5
-58
lines changed

src/Lexer.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,18 +788,21 @@ protected function scanTableRow()
788788

789789
private function parseTableCell(string $cell): string
790790
{
791+
$trimmedCell = preg_replace('/^[ \\t\\n\\x0B\\f\\r\\x85\\xA0]++|[ \\t\\n\\x0B\\f\\r\\x85\\xA0]++$/u', '', $cell);
792+
\assert($trimmedCell !== null);
793+
791794
$value = preg_replace_callback('/\\\\./', function (array $matches) {
792795
return match ($matches[0]) {
793796
'\\n' => "\n",
794797
'\\\\' => '\\',
795798
'\\|' => '|',
796799
default => $matches[0],
797800
};
798-
}, $cell);
801+
}, $trimmedCell);
799802

800803
assert($value !== null);
801804

802-
return trim($value, ' ');
805+
return $value;
803806
}
804807

805808
/**

tests/Cucumber/CompatibilityTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class CompatibilityTest extends TestCase
6767
'rule.feature' => 'Rule keyword not supported',
6868
'rule_with_tag.feature' => 'Rule keyword not supported',
6969
'tags.feature' => 'Rule keyword not supported',
70-
'padded_example.feature' => 'Table padding is not trimmed as aggressively',
7170
'rule_without_name_and_description.feature' => 'Rule is wrongly parsed as Description',
7271
],
7372
];

tests/Cucumber/expected_variants/gherkin-32/padded_example.feature.expected.yaml

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)