diff --git a/src/Behat/Gherkin/Lexer.php b/src/Behat/Gherkin/Lexer.php index 3b03768c..d6992dff 100644 --- a/src/Behat/Gherkin/Lexer.php +++ b/src/Behat/Gherkin/Lexer.php @@ -179,6 +179,15 @@ protected function consumeLine() $this->trimmedLine = null; } + /** + * Consumes first part of line from input without incrementing the line number + */ + protected function consumeLineUntil(int $trimmedOffset) + { + $this->line = mb_substr(ltrim($this->line), $trimmedOffset, null, 'utf-8'); + $this->trimmedLine = null; + } + /** * Returns trimmed version of line. * @@ -502,17 +511,24 @@ protected function scanTableRow() protected function scanTags() { $line = $this->getTrimmedLine(); - $line = preg_replace('/\s+#.*$/', '', $line); + if (!isset($line[0]) || '@' !== $line[0]) { return null; } + if(preg_match('/^(?.*)\s+#.*$/', $line, $matches)) { + ['line' => $line] = $matches; + $this->consumeLineUntil(mb_strlen($line, 'utf-8')); + } + else { + $this->consumeLine(); + } + $token = $this->takeToken('Tag'); $tags = explode('@', mb_substr($line, 1, mb_strlen($line, 'utf8') - 1, 'utf8')); $tags = array_map('trim', $tags); $token['tags'] = $tags; - $this->consumeLine(); return $token; }