Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Fachgruppenwebseite Metadaten
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
fginfo
Fachgruppenwebseite Metadaten
Commits
bc5cb448
Verified
Commit
bc5cb448
authored
2 years ago
by
Jake
Browse files
Options
Downloads
Patches
Plain Diff
parse tables
parent
d4c95820
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#317731
passed
2 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fgs/pandoc.py
+88
-2
88 additions, 2 deletions
fgs/pandoc.py
with
88 additions
and
2 deletions
fgs/pandoc.py
+
88
−
2
View file @
bc5cb448
...
...
@@ -181,6 +181,12 @@ class Element():
def
parse_int
(
self
,
raw_num
):
return
raw_num
# TODO
def
parse_double_as_percentage
(
self
,
raw_num
):
res
=
{}
res
[
"
raw
"
]
=
raw_num
res
[
"
percentage
"
]
=
raw_num
*
100
return
res
def
parse_target
(
self
,
raw_target
):
# For URLs
res
=
{}
rawurl
=
self
.
parse_text
(
raw_target
[
0
])
...
...
@@ -368,8 +374,88 @@ class BlockTable(Block): # Attr Caption [ColSpec] TableHead [TableBody] TableFoo
]
"""
self
.
attr
=
self
.
parse_attr
(
pandocraw
[
0
])
# TODO continue
raise
Exception
(
pandocraw
)
self
.
caption
=
self
.
parse_caption
(
pandocraw
[
1
])
self
.
column_specs
=
self
.
parse_column_specs
(
pandocraw
[
2
])
self
.
head
=
self
.
parse_head
(
pandocraw
[
3
])
self
.
bodies
=
self
.
parse_bodies
(
pandocraw
[
4
])
self
.
foot
=
self
.
parse_foot
(
pandocraw
[
5
])
def
parse_caption
(
self
,
raw_caption
):
#print("called parse_caption: ", raw_caption)
if
raw_caption
[
0
]
!=
None
:
print
(
"
Warning: Found table with unsupported short caption:
"
,
raw_caption
,
file
=
sys
.
stderr
)
return
self
.
parse_blocks
(
raw_caption
[
1
])
def
parse_column_specs
(
self
,
raw_column_specs
):
#print("called parse_column_specs: ", raw_column_specs)
res
=
[]
for
cur
in
raw_column_specs
:
colspec
=
{}
colspec
[
"
alignment
"
]
=
self
.
parse_alignment
(
cur
[
0
])
if
cur
[
1
][
'
t
'
]
==
"
ColWidthDefault
"
:
colspec
[
"
has_width
"
]
=
False
else
:
colspec
[
"
has_width
"
]
=
True
colspec
[
"
width
"
]
=
self
.
parse_double_as_percentage
(
cur
[
1
][
'
c
'
])
res
.
append
(
colspec
)
return
res
def
parse_alignment
(
self
,
raw_alignment
):
return
self
.
parse_enum
({
"
AlignLeft
"
:
"
left
"
,
"
AlignRight
"
:
"
right
"
,
"
AlignCenter
"
:
"
center
"
,
"
AlignDefault
"
:
"
default
"
},
raw_alignment
)
def
parse_cells
(
self
,
raw_cells
):
cells
=
[]
for
cur
in
raw_cells
:
cell
=
{}
cell
[
"
attr
"
]
=
self
.
parse_attr
(
cur
[
0
])
cell
[
"
alignment
"
]
=
self
.
parse_alignment
(
cur
[
1
])
cell
[
"
row_span
"
]
=
self
.
parse_int
(
cur
[
2
])
# number of rows occupied by a cell; the height of a cell
cell
[
"
column_span
"
]
=
self
.
parse_int
(
cur
[
3
])
# number of columns occupied by a cell; the width of a cell
cell
[
"
content
"
]
=
self
.
parse_blocks
(
cur
[
4
])
cells
.
append
(
cell
)
return
cells
def
parse_rows
(
self
,
raw_rows
):
rows
=
[]
for
cur
in
raw_rows
:
row
=
{}
row
[
"
attr
"
]
=
self
.
parse_attr
(
cur
[
0
])
row
[
"
cells
"
]
=
self
.
parse_cells
(
cur
[
1
])
rows
.
append
(
row
)
return
rows
def
parse_head
(
self
,
raw_head
):
#print("called parse_head: ", raw_head)
res
=
{}
res
[
"
attr
"
]
=
self
.
parse_attr
(
raw_head
[
0
])
res
[
"
rows
"
]
=
self
.
parse_rows
(
raw_head
[
1
])
return
res
def
parse_bodies
(
self
,
raw_bodies
):
#print("called parse_bodies: ", raw_bodies)
bodies
=
[]
for
cur
in
raw_bodies
:
body
=
{}
body
[
"
attr
"
]
=
self
.
parse_attr
(
cur
[
0
])
body
[
"
row_head_columns
"
]
=
self
.
parse_int
(
cur
[
1
])
# number of row header columns in the intermediate body
body
[
"
intermediate_head
"
]
=
self
.
parse_rows
(
cur
[
2
])
body
[
"
intermediate_body
"
]
=
self
.
parse_rows
(
cur
[
3
])
bodies
.
append
(
body
)
return
bodies
def
parse_foot
(
self
,
raw_foot
):
#print("called parse_foot: ", raw_foot)
res
=
{}
res
[
"
attr
"
]
=
self
.
parse_attr
(
raw_foot
[
0
])
res
[
"
rows
"
]
=
self
.
parse_rows
(
raw_foot
[
1
])
return
res
############################## INLINE #########################################
...
...
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