diff options
author | Gaurav Jain <gaurav@gauravjain.org> | 2014-04-27 11:35:02 -0400 |
---|---|---|
committer | Gaurav Jain <gaurav@gauravjain.org> | 2014-04-27 11:35:02 -0400 |
commit | 603816096833d0f930210517876a72f4af6b4cfd (patch) | |
tree | 689b8fea1dc47545979bfc45411f74e88e1a5d01 | |
parent | 0c7f160e848d472bbe8f0e277b4f11dece859cc0 (diff) | |
download | pygments-603816096833d0f930210517876a72f4af6b4cfd.tar.gz |
Gherkin: Comments should only be matched on distinct lines
According to https://github.com/cucumber/cucumber/wiki/Gherkin, cooments are complete lines that can appear anywhere in the file and
have leading whitespace.
Added valid example file which was validated with 'cucumber -r -d tests/examplefiles/example.feature'
-rw-r--r-- | pygments/lexers/other.py | 3 | ||||
-rw-r--r-- | tests/examplefiles/example.feature | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 47a4b865..acec8bb1 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -1866,7 +1866,7 @@ class GherkinLexer(RegexLexer): tokens = { 'comments': [ - (r'#.*$', Comment), + (r'^\s*#.*$', Comment), ], 'feature_elements' : [ (step_keywords, Keyword, "step_content_stack"), @@ -1895,6 +1895,7 @@ class GherkinLexer(RegexLexer): ], 'narrative': [ include('scenario_sections_on_stack'), + include('comments'), (r"(\s|.)", Name.Function), ], 'table_vars': [ diff --git a/tests/examplefiles/example.feature b/tests/examplefiles/example.feature new file mode 100644 index 00000000..a26268da --- /dev/null +++ b/tests/examplefiles/example.feature @@ -0,0 +1,16 @@ +# First comment +Feature: My amazing feature + Feature description line 1 + Feature description line 2 + +#comment +Scenario Outline: My detailed scenario #string + Given That <x> is set + When When I <subtract> + Then I should get the <remain#der> + + # indented comment + Examples: + | x | subtract | remain#der | + | 12 | 5\|3 | #73 | + | #the | 10 | 15 | |