Commit dfab5367 authored by ankraft's avatar ankraft
Browse files

Corrected width of multiline cells

parent bceb793c
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+3 −0
Original line number Original line Diff line number Diff line
out
.vscode
__pycache__
+5 −2
Original line number Original line Diff line number Diff line
@@ -94,7 +94,7 @@ def formatGridTable(lines: list[str]) -> list[str]:
		return lines
		return lines


	# Get column widths from first separator line
	# Get column widths from first separator line
	colWidths = [len(col.strip()) for col in lines[0].split('+')[1:-1]]
	colWidths = [0] * (lines[0].count('+') - 1)
	result = []
	result = []


	# Adjust column widths if any cell is longer
	# Adjust column widths if any cell is longer
@@ -105,7 +105,10 @@ def formatGridTable(lines: list[str]) -> list[str]:
			for i, cell in enumerate(rowCells):
			for i, cell in enumerate(rowCells):
				if i >= len(colWidths):
				if i >= len(colWidths):
					continue
					continue
				cellWidth = len(cell.strip())
				# Calculate maximum width of each line in the cell. Lines could be multilines, so we need to split them.
				cellLines = cell.strip().split('\\\n')
				cellWidth = max(len(line.strip()) if line != colspanMarker else 0
								for line in cellLines)
				if cellWidth > colWidths[i]:
				if cellWidth > colWidths[i]:
					colWidths[i] = cellWidth
					colWidths[i] = cellWidth