Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Scripts
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
Releases
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
Scripts
Commits
a88ef036
Commit
a88ef036
authored
4 months ago
by
Miguel Angel Reina Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Fixing setting of cell alignment
parent
2bf10c26
No related branches found
No related tags found
1 merge request
!1
Restructuring and cleaning scripts for Mkdocs
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
toMkdocs/gridTableTools.py
+6
-7
6 additions, 7 deletions
toMkdocs/gridTableTools.py
with
6 additions
and
7 deletions
toMkdocs/gridTableTools.py
+
6
−
7
View file @
a88ef036
...
...
@@ -39,6 +39,7 @@ class GridCell:
self
.
colspan
:
int
=
0
self
.
colspanAdjusted
:
bool
=
False
self
.
alignment
:
str
=
'
align=
"
center
"'
self
.
positionStart
:
Optional
[
int
]
=
None
self
.
position
:
Optional
[
int
]
=
None
self
.
listFlag
:
bool
=
False
self
.
auxiliarIndex
:
int
=
0
...
...
@@ -57,19 +58,15 @@ class GridCell:
defaultAlignments: The default alignments.
hasHeader: True if the table has a header, False otherwise.
"""
if
self
.
position
is
None
:
if
self
.
position
is
None
or
self
.
positionStart
is
None
:
raise
ValueError
(
'
Cell position must be set before calculating alignment.
'
)
if
hasHeader
:
headerDelimiterIndex
=
0
while
headerDelimiterIndex
<
len
(
defaultAlignments
)
and
self
.
position
>
headerDelimiterPositions
[
headerDelimiterIndex
]:
while
headerDelimiterIndex
<
len
(
defaultAlignments
)
and
self
.
position
Start
>
headerDelimiterPositions
[
headerDelimiterIndex
]:
headerDelimiterIndex
+=
1
if
headerDelimiterIndex
<
len
(
defaultAlignments
):
if
self
.
position
<
headerDelimiterPositions
[
headerDelimiterIndex
]:
self
.
alignment
=
defaultAlignments
[
headerDelimiterIndex
]
elif
self
.
position
==
headerDelimiterPositions
[
headerDelimiterIndex
]:
self
.
alignment
=
defaultAlignments
[
headerDelimiterIndex
]
headerDelimiterIndex
+=
1
else
:
raise
ValueError
(
'
Invalid table formatting
'
)
...
...
@@ -364,6 +361,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR
cell
=
rows
[
-
1
][
columnIndex
]
# Set position
cell
.
positionStart
=
delimiterIndex
-
len
(
parts
[
rowIndex
])
cell
.
position
=
delimiterIndex
# Position of cell delimiter +
# Set alignment as defined by header separator line
...
...
@@ -390,6 +388,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR
if
auxiliarCellIndex
<
numberOfColumns
:
auxDelimiterIndex
+=
len
(
content
)
+
1
cell
=
rows
[
-
1
][
auxiliarCellIndex
]
cell
.
positionStart
=
auxDelimiterIndex
-
len
(
content
)
# Position of cell delimiter +
cell
.
position
=
auxDelimiterIndex
# Position of cell delimiter +
cell
.
calculateAndSetAlignment
(
headerDelimiterPositions
,
delimiterPositions
,
defaultAlignments
,
hasHeader
)
while
auxDelimiterIndex
>
delimiterPositions
[
auxiliarCellIndex
]:
...
...
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