diff --git a/src/Behat/Gherkin/Lexer.php b/src/Behat/Gherkin/Lexer.php index 76731914..f8957f30 100644 --- a/src/Behat/Gherkin/Lexer.php +++ b/src/Behat/Gherkin/Lexer.php @@ -38,6 +38,7 @@ class Lexer private $featureStarted = false; private $allowMultilineArguments = false; private $allowSteps = false; + private $pyStringDelimiter = null; /** * Initializes lexer. @@ -435,13 +436,25 @@ protected function scanPyStringOp() return null; } - if (false === ($pos = mb_strpos($this->line, '"""', 0, 'utf8'))) { + if(!preg_match('/^\s*(?"""|```)/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(); diff --git a/tests/Behat/Gherkin/Cucumber/CompatibilityTest.php b/tests/Behat/Gherkin/Cucumber/CompatibilityTest.php index 76d7a0c7..cefa7ec0 100644 --- a/tests/Behat/Gherkin/Cucumber/CompatibilityTest.php +++ b/tests/Behat/Gherkin/Cucumber/CompatibilityTest.php @@ -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',