def table_cells(row):
    """
    An iterator returning all the table cells in a row, accounting for
    escaping.
    """

    row = iter(row)
    cell = ''
    while True:
        char = next(row, None)
        if char == '|':
            yield cell
            cell = ''
        elif char == '\\':
            char = next(row)
            if char == 'n':
                cell += '\n'
            else:
                cell += char
        elif char:
            cell += char
        else:
            break
    yield cell


class GherkinLine:
    def __init__(self, line_text, line_number):
        self._line_text = line_text
        self._line_number = line_number
        self._trimmed_line_text = line_text.lstrip()
        self.indent = len(line_text) - len(self._trimmed_line_text)

    def get_rest_trimmed(self, length):
        return self._trimmed_line_text[length:].strip()

    def get_line_text(self, indent_to_remove=-1):
        if indent_to_remove < 0 or indent_to_remove > self.indent:
            return self._trimmed_line_text
        else:
            return self._line_text[indent_to_remove:]

    def is_empty(self):
        return not self._trimmed_line_text

    def startswith(self, prefix):
        return self._trimmed_line_text.startswith(prefix)

    def startswith_title_keyword(self, keyword):
        return self._trimmed_line_text.startswith(keyword + ':')

    def table_cells(self):
        column = self.indent + 1
        items = list(table_cells(self._trimmed_line_text.strip()))
        cells = []
        for item in items[1:-1]:
            cell_indent = len(item) - len(item.lstrip()) + 1
            cells.append({'column': column + cell_indent, 'text': item.strip()})
            column += len(item) + 1
        return cells

    def tags(self):
        column = self.indent + 1
        items = self._trimmed_line_text.strip().split('@')
        tags = []
        for item in items[1:]:
            tags.append({'column': column, 'text': '@' + item.strip()})
            column += len(item) + 1
        return tags

@@ -1,529 +1,4 @@
-def table_cells(row):%0A    %22%22%22%0A    An iterator returning all the table cells in a row, accounting for%0A    escaping.%0A    %22%22%22%0A%0A    row = iter(row)%0A    cell = ''%0A    while True:%0A        char = next(row, None)%0A        if char == '%7C':%0A            yield cell%0A            cell = ''%0A        elif char == '%5C%5C':%0A            char = next(row)%0A            if char == 'n':%0A                cell += '%5Cn'%0A            else:%0A                cell += char%0A        elif char:%0A            cell += char%0A        else:%0A            break%0A    yield cell%0A
 %0A%0Acl
@@ -902,149 +902,98 @@
    c
-olumn = self.indent + 1%0A        items = list(table_cells(self._trimmed_line_text.strip()))%0A        cells = %5B%5D%0A        for item in items%5B1:-1%5D
+ells = %5B%5D%0A        for cell, col in self.split_table_cells(self._trimmed_line_text.strip())
 :%0A  
@@ -1024,20 +1024,20 @@
 len(
-item
+cell
 ) - len(
 item
@@ -1032,20 +1032,20 @@
 ) - len(
-item
+cell
 .lstrip(
@@ -1046,20 +1046,16 @@
 strip())
- + 1
 %0A       
@@ -1086,19 +1086,30 @@
 mn': col
-umn
+ + self.indent
  + cell_
@@ -1124,20 +1124,20 @@
 'text': 
-item
+cell
 .strip()
@@ -1151,56 +1151,1044 @@
     
-    column += len(item) + 1%0A        return cells
+return cells%0A%0A    def split_table_cells(self, row):%0A        %22%22%22%0A        An iterator returning all the table cells in a row with their positions,%0A        accounting for escaping.%0A        %22%22%22%0A%0A        row = iter(row)%0A        col = 0%0A        start_col = col + 1%0A        cell = ''%0A        first_cell = True%0A        while True:%0A            char = next(row, None)%0A            col += 1%0A            if char == '%7C':%0A                if first_cell:%0A                    # First cell (content before the first %7C) is skipped%0A                    first_cell = False%0A                else:%0A                    yield (cell, start_col)%0A                cell = ''%0A                start_col = col + 1%0A            elif char == '%5C%5C':%0A                char = next(row)%0A                col += 1%0A                if char == 'n':%0A                    cell += '%5Cn'%0A                else:%0A                    cell += char%0A            elif char:%0A                cell += char%0A            else:%0A                break%0A        # Last cell (content after the last %7C) is skipped
 %0A%0A  

fix column positions