| 151 | } |
| 152 | |
| 153 | function rewriteRow(row: string, separator: boolean) { |
| 154 | // Preserve leading whitespace of the row itself (table indentation). |
| 155 | const indent = row.match(/^\s*/)![0]; |
| 156 | const body = row.slice(indent.length); |
| 157 | const cells = split(body); |
| 158 | if (cells.length === 0) return row; |
| 159 | if (separator) return `${indent}|${cells.map(fixSepCell).join('|')}|`; |
| 160 | return `${indent}| ${cells.map(c => c.trim()).join(' | ')} |`; |
| 161 | } |
| 162 | |
| 163 | function fix(file: string) { |
| 164 | const src = readFileSync(path.join(ROOT, file), 'utf8'); |