| 26 | |
| 27 | |
| 28 | def escapedSplit(string: str) -> list[str]: |
| 29 | result: list[str] = [] |
| 30 | pos = 0 |
| 31 | max = len(string) |
| 32 | isEscaped = False |
| 33 | lastPos = 0 |
| 34 | current = "" |
| 35 | ch = charStrAt(string, pos) |
| 36 | |
| 37 | while pos < max: |
| 38 | if ch == "|": |
| 39 | if not isEscaped: |
| 40 | # pipe separating cells, '|' |
| 41 | result.append(current + string[lastPos:pos]) |
| 42 | current = "" |
| 43 | lastPos = pos + 1 |
| 44 | else: |
| 45 | # escaped pipe, '\|' |
| 46 | current += string[lastPos : pos - 1] |
| 47 | lastPos = pos |
| 48 | |
| 49 | isEscaped = ch == "\\" |
| 50 | pos += 1 |
| 51 | |
| 52 | ch = charStrAt(string, pos) |
| 53 | |
| 54 | result.append(current + string[lastPos:]) |
| 55 | |
| 56 | return result |
| 57 | |
| 58 | |
| 59 | def table(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool: |