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
fa8d7f0d
Verified
Commit
fa8d7f0d
authored
2 years ago
by
Jake
Browse files
Options
Downloads
Patches
Plain Diff
added page.metadata.image and ability to iterate over all elements inside a list of elements
parent
98c09019
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fgs/pandoc.py
+24
-0
24 additions, 0 deletions
fgs/pandoc.py
with
24 additions
and
0 deletions
fgs/pandoc.py
+
24
−
0
View file @
fa8d7f0d
...
@@ -48,6 +48,7 @@ def run_pandoc(source, factories, lang, base="markdown", extensions=[], extra_ar
...
@@ -48,6 +48,7 @@ def run_pandoc(source, factories, lang, base="markdown", extensions=[], extra_ar
if
block
!=
None
:
if
block
!=
None
:
blocks
.
append
(
block
)
blocks
.
append
(
block
)
elementlist
=
convert_elements_to_list
(
blocks
)
contentmetadata
=
{}
contentmetadata
=
{}
contentmetadata
[
"
toc_list
"
]
=
[]
contentmetadata
[
"
toc_list
"
]
=
[]
...
@@ -56,10 +57,33 @@ def run_pandoc(source, factories, lang, base="markdown", extensions=[], extra_ar
...
@@ -56,10 +57,33 @@ def run_pandoc(source, factories, lang, base="markdown", extensions=[], extra_ar
# TODO TOC
# TODO TOC
#contentmetadata["toc"] = build_toc(n["toc_list"].copy())
#contentmetadata["toc"] = build_toc(n["toc_list"].copy())
# Get all images on page
images
=
[]
for
e
in
elementlist
:
if
e
.
etype
==
"
image
"
:
images
.
append
(
e
)
contentmetadata
[
"
images
"
]
=
images
contentmetadata
[
"
has_image
"
]
=
(
len
(
images
)
>
0
)
if
contentmetadata
[
"
has_image
"
]:
contentmetadata
[
"
image
"
]
=
images
[
0
]
#blocks = json.loads(json.dumps(blocks, cls=ElementEncoder)) # Reduce to 'simple' dict, which can be converted to JSON in Jinja2.
#blocks = json.loads(json.dumps(blocks, cls=ElementEncoder)) # Reduce to 'simple' dict, which can be converted to JSON in Jinja2.
return
(
blocks
,
contentmetadata
)
return
(
blocks
,
contentmetadata
)
def
convert_elements_to_list
(
elements
):
res
=
[]
for
element
in
elements
:
res
.
append
(
element
)
res
+=
convert_elements_to_list
(
element
.
children
)
return
res
def
parse_from_register
(
factories
,
lang
,
reg
:
dict
,
h
:
dict
,
custom_syntax_handler
):
def
parse_from_register
(
factories
,
lang
,
reg
:
dict
,
h
:
dict
,
custom_syntax_handler
):
t
=
h
[
'
t
'
]
# pandoc type
t
=
h
[
'
t
'
]
# pandoc type
if
t
not
in
reg
:
if
t
not
in
reg
:
...
...
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