Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
spec2md
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Specification Tools
spec2md
Commits
dfab5367
Commit
dfab5367
authored
2 months ago
by
Andreas Kraft
Browse files
Options
Downloads
Patches
Plain Diff
Corrected width of multiline cells
parent
bceb793c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+3
-0
3 additions, 0 deletions
.gitignore
gridTable.py
+5
-2
5 additions, 2 deletions
gridTable.py
with
8 additions
and
2 deletions
.gitignore
0 → 100644
+
3
−
0
View file @
dfab5367
out
.vscode
__pycache__
This diff is collapsed.
Click to expand it.
gridTable.py
+
5
−
2
View file @
dfab5367
...
@@ -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
].
spli
t
(
'
+
'
)
[
1
:
-
1
]]
colWidths
=
[
0
]
*
(
lines
[
0
].
coun
t
(
'
+
'
)
-
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment