Skip to content
Snippets Groups Projects
Commit dfab5367 authored by Andreas Kraft's avatar Andreas Kraft
Browse files

Corrected width of multiline cells

parent bceb793c
No related branches found
No related tags found
No related merge requests found
out
.vscode
__pycache__
...@@ -94,7 +94,7 @@ def formatGridTable(lines: list[str]) -> list[str]: ...@@ -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]: ...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment