function computeElasticTabs(text) {
const table = text.split("\n").map(line => line.split("\t").slice(0, -1));
const tableUnpruned = text.split("\n").map(line => line.split("\t"));
const cellBlocks = {};
const blockWidths = [];
const numRows = table.length;
const numCols = Math.max(...table.map(cells => cells.length));
const getCell = (r, c) => ({ r, c, text: table[r][c] });
for (const c of range(numCols)) {
const column = range(numRows)
.map(r => getCell(r, c))
.filter(({ text }) => text != null);
const blocks = splitArray(column, (curr, prev) => curr.r !== prev.r + 1);
for (const cells of blocks) {
const w = Math.max(...cells.map(({ text }) => text.length));
const blockI = blockWidths.length;
for (const { r } of cells) {
cellBlocks[`${r},${c}`] = blockI;
}
blockWidths.push(w);
}
}
return { table: tableUnpruned, cellBlocks, blockWidths };
}