Skip to content

Commit

Permalink
Escape newline characters in table cells
Browse files Browse the repository at this point in the history
Resolve #51
  • Loading branch information
ducminh-phan committed Jan 29, 2022
1 parent 63fd988 commit 241ba0d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion reformat_gherkin/ast_node/table_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def escape_table_cell_value(text: str) -> str:
are used to separate cells in a row, we need to replace them by `\\|`.
"""

return text.replace("|", "\\|")
return text.replace("|", "\\|").replace("\n", "\\n")


@prepare
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Breaking gherkin reformatter

Scenario Outline:
Given I want to cause a bug
When I try to reformat with an example table with a message like <message>
Then gherkin reformatter explodes

Examples:
| message |
| a\| b\n c\r d\t e\r\n f |
10 changes: 10 additions & 0 deletions tests/data/valid/special_characters_in_table_cell/input.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Breaking gherkin reformatter

Scenario Outline:
Given I want to cause a bug
When I try to reformat with an example table with a message like <message>
Then gherkin reformatter explodes

Examples:
| message |
| a\| b\n c\r d\t e\r\n f\n |

0 comments on commit 241ba0d

Please sign in to comment.