Skip to content
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

Support alternative docstrings format (```) #214

Merged
merged 2 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/Behat/Gherkin/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Lexer
private $featureStarted = false;
private $allowMultilineArguments = false;
private $allowSteps = false;
private $pyStringDelimiter = null;

/**
* Initializes lexer.
Expand Down Expand Up @@ -435,13 +436,25 @@ protected function scanPyStringOp()
return null;
}

if (false === ($pos = mb_strpos($this->line, '"""', 0, 'utf8'))) {
if(!preg_match('/^\s*(?<delimiter>"""|```)/u', $this->line, $matches, PREG_OFFSET_CAPTURE)) {
return null;
}

['delimiter' => [0 => $delimiter, 1 => $indent]] = $matches;

if ($this->inPyString) {
if ($this->pyStringDelimiter !== $delimiter) {
return null;
}
$this->pyStringDelimiter = null;
}
else {
$this->pyStringDelimiter= $delimiter;
}

$this->inPyString = !$this->inPyString;
$token = $this->takeToken('PyStringOp');
$this->pyStringSwallow = $pos;
$this->pyStringSwallow = $indent;

$this->consumeLine();

Expand Down
1 change: 0 additions & 1 deletion tests/Behat/Gherkin/Cucumber/CompatibilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class CompatibilityTest extends TestCase
'complex_background.feature' => 'Rule keyword not supported',
'rule.feature' => 'Rule keyword not supported',
'descriptions.feature' => 'Examples table descriptions not supported',
'docstrings.feature' => 'Docstrings with ``` separators not supported',
'incomplete_scenario_outline.feature' => 'Scenario and Scenario outline not yet synonyms',
'padded_example.feature' => 'Scenario and Scenario outline not yet synonyms',
'scenario_outline.feature' => 'Scenario and Scenario outline not yet synonyms',
Expand Down