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

Retain leading white space in table nodes #104

Closed
rudiedirkx opened this issue Mar 26, 2016 · 2 comments
Closed

Retain leading white space in table nodes #104

rudiedirkx opened this issue Mar 26, 2016 · 2 comments

Comments

@rudiedirkx
Copy link

Imagine you have an Examples table like this:

Examples:
    | Quantity    | StartAmount | StartUnit | ResultAmount | ResultUnit |
    | Volume      |    1        | l         |    1         | l          |
    | Volume      |  350        | usg       | 1324.8935    | l          |
    | Volume      | 1000        | l         |  264.1722    | usg        |
    | Volume      | 1000        | l         |  219.9692    | bg         |
    | Volume      |   80        | bg        |   96.0760    | usg        |

Parsing and printing that table would print:

| Quantity | StartAmount | StartUnit | ResultAmount | ResultUnit |
| Volume   | 1           | l         | 1            | l          |
| Volume   | 350         | usg       | 1324.8935    | l          |
| Volume   | 1000        | l         | 264.1722     | usg        |
| Volume   | 1000        | l         | 219.9692     | bg         |
| Volume   | 80          | bg        | 96.0760      | usg        |

because leading white spaces aren't remembered after parsing. It'd be so nice to keep them, to print the exact same table as was input.

Obviously it's not very important, but it is nice. And it's possible and backward compatible, but it's not very pretty. I had to alter the Lexer (parse the table and keep left padding) and the TableNode (remove left padding from values, but save their sizes).

I'll create a pull request.

@stof
Copy link
Member

stof commented Jun 16, 2016

sorry, but the existing behavior matches the behavior of the official gherkin parsers (which explicitly mandate that table cells are trimmed from their whitespaces), so we won't diverge from it in our own parser.

@stof stof closed this as completed Jun 16, 2016
@stof
Copy link
Member

stof commented Jun 16, 2016

and btw, this is not backward compatible, as it changes the behavior of formatted cells

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants