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 1 commit
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
16 changes: 14 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 = false;
ciaranmcnulty marked this conversation as resolved.
Show resolved Hide resolved

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

if (false === ($pos = mb_strpos($this->line, '"""', 0, 'utf8'))) {
if ((false === ($indent = mb_strpos($this->line, $delimiter = '"""', 0, 'utf8')))
&& (false === ($indent = mb_strpos($this->line, $delimiter ='```', 0, 'utf8')))) {
ciaranmcnulty marked this conversation as resolved.
Show resolved Hide resolved
return null;
}

if ($this->inPyString) {
if ($this->pyStringDelimiter !== $delimiter) {
return null;
}
$this->pyStringDelimiter = false;
}
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