(row: string)
| 48 | type Issue = { file: string; line: number; kind: 'separator' | 'content'; detail: string }; |
| 49 | |
| 50 | function split(row: string) { |
| 51 | // Split on unescaped pipes, drop the empty leading/trailing cells that come |
| 52 | // from rows starting and ending with a pipe. |
| 53 | const cells: string[] = []; |
| 54 | let buf = ''; |
| 55 | for (let i = 0; i < row.length; i++) { |
| 56 | const c = row[i]; |
| 57 | if (c === '\\' && row[i + 1] === '|') { |
| 58 | buf += '\\|'; |
| 59 | i++; |
| 60 | continue; |
| 61 | } |
| 62 | if (c === '|') { |
| 63 | cells.push(buf); |
| 64 | buf = ''; |
| 65 | continue; |
| 66 | } |
| 67 | buf += c; |
| 68 | } |
| 69 | cells.push(buf); |
| 70 | if (cells.length >= 2 && cells[0].trim() === '') cells.shift(); |
| 71 | if (cells.length >= 1 && cells[cells.length - 1].trim() === '') cells.pop(); |
| 72 | return cells; |
| 73 | } |
| 74 | |
| 75 | function isSep(row: string) { |
| 76 | // A separator row contains only pipes, dashes, colons, and spaces, and has |
no test coverage detected