question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible to get table cell strings with leading/trailing spaces?

See original GitHub issue

The OSRM route engine uses tables to define small ‘maps’ of node locations used in tests, ie:

            |   |   | a |   |   |
            |   |   | b |   |   |
            | d | c |   | g | h |
            |   |   | e |   |   |
            |   |   | f |   |   |

The horizontal and vertical position of nodes are translated to latitude and longitude. This might be a somewhat unusual use of tables, but it’s very useful.

To make the maps easier to read I would like simplify the syntax to:

            |     a     |
            |     b     |
            | d c   g h |
            |     e     |
            |     f     |

However cucumber strips leading (and trailing) spaces from the cell strings, ie. " a " is returned as “a”, which breaks the horizontal positions.

Is there any way to get the raw strings including the leading spaces?

I guess we could quote all lines, but this is awkward. I looked at transforms, but it seems cucumber js doesn’t implement it, and anyways I’m not sure it would solve the problem?

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
charlierudolphcommented, Sep 20, 2016

It appears that trimming of trailing and leading whitespace is done by gherkin and as far as I can tell there is no way to ask gherkin to preserve them. You could open an issue on gherkin if you would like.

I believe transforms are mostly for capture groups in regular expressions, though cucumber-ruby has data table transforms. That would start with the data gherkin parses though, so you would have already lost the leading and trailing spaces.

If all you want is the example you gave, you could try using doc strings.

Given my map
  """
      a     
      b     
  d c   g h 
      e    
      f    
  """
0reactions
lock[bot]commented, Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sql - Look for trailing spaces in a table - Stack Overflow
Another way might be to append something on the string. declare @test table ...
Read more >
How to remove leading and/or trailing spaces of a string in T ...
Use the TRIM function if you want to trim a string in a table. This function allows you to remove a specific character...
Read more >
How to find values with Leading or Trailing Spaces in SQL ...
Solution: Let's create our test temp table with some test data. I have included leading and trailing space in 4 values.
Read more >
How to find leading and trailing spaces in a varchar2 column
Answer: Finding leading spaces in a table column is easy with the substr function: select mycol from mytab where substr(mycol,1,1) = ' ';....
Read more >
How to find values in a column has leading and trailing space
I have a table with ContractID column...which has n number of records.. i want to filter those columns which has leading and trailing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found