Skip to content

Commit

Permalink
Merge pull request #30 from mapado/escape-multi-pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeniau authored Sep 2, 2024
2 parents d2e11ec + 30ddb28 commit 6ce0894
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GherkinAST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function isWithLocation(node: unknown): node is GherkinNodeWithLocation {
function reEscapeTableCell(str: string): string {
const out = str
// espace all pipes that have been unescaped
.replace('|', '\\|')
.replaceAll('|', '\\|')
// espace all backslashes that have been unescaped
.replace(/\\/g, '\\\\');

Expand Down
12 changes: 12 additions & 0 deletions tests/good/__snapshots__/jsfmt.spec.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,9 @@ Feature: Escaped pipes
| \\|æ\\\\n | \\o\\no\\ |
| \\\\\\|a\\\\\\\\n | ø\\\\\\nø\\\\|
When I escape several pipes
| a \\| b \\| c | d \\| e \\| f |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
options: {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -849,6 +852,9 @@ Feature: Escaped pipes
| \\|æ\\\\n | \\o\\no\\ |
| \\\\\\|a\\\\\\\\n | ø\\\\\\nø\\ |
When I escape several pipes
| a \\| b \\| c | d \\| e \\| f |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
options: {
"tabWidth": 4
Expand All @@ -866,6 +872,9 @@ Feature: Escaped pipes
| \\|æ\\\\n | \\o\\no\\ |
| \\\\\\|a\\\\\\\\n | ø\\\\\\nø\\ |
When I escape several pipes
| a \\| b \\| c | d \\| e \\| f |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
options: {
"forceNewlineBetweenStepBlocks": true
Expand All @@ -884,6 +893,9 @@ Feature: Escaped pipes
| \\|æ\\\\n | \\o\\no\\ |
| \\\\\\|a\\\\\\\\n | ø\\\\\\nø\\ |
When I escape several pipes
| a \\| b \\| c | d \\| e \\| f |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`;
Expand Down
3 changes: 3 additions & 0 deletions tests/good/escaped_pipes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ Feature: Escaped pipes
Given they have arrived
| \|æ\\n | \o\no\ |
| \\\|a\\\\n | ø\\\nø\\|

When I escape several pipes
| a \| b \| c | d \| e \| f |

0 comments on commit 6ce0894

Please sign in to comment.