Skip to content
Snippets Groups Projects
Verified Commit 9943cdeb authored by Jake's avatar Jake
Browse files

updated CustomBlockTOC

parent ae502fee
No related branches found
No related tags found
No related merge requests found
Pipeline #328348 passed
...@@ -52,7 +52,6 @@ def run_pandoc(source, factories, lang, base="markdown", extensions=[], extra_ar ...@@ -52,7 +52,6 @@ def run_pandoc(source, factories, lang, base="markdown", extensions=[], extra_ar
contentmetadata = {} contentmetadata = {}
# Get all images on page # Get all images on page
images = [] images = []
for e in elementlist: for e in elementlist:
...@@ -73,6 +72,10 @@ def run_pandoc(source, factories, lang, base="markdown", extensions=[], extra_ar ...@@ -73,6 +72,10 @@ def run_pandoc(source, factories, lang, base="markdown", extensions=[], extra_ar
# Add Table-of-Contents # Add Table-of-Contents
contentmetadata["toc"] = build_toc(headers) contentmetadata["toc"] = build_toc(headers)
# Add Table-of-Contents information to "toc" elements.
for e in elementlist:
if e.etype == "toc":
e.toc = contentmetadata["toc"]
#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.
...@@ -758,7 +761,7 @@ class CustomSyntaxHandler: ...@@ -758,7 +761,7 @@ class CustomSyntaxHandler:
class CustomBlockTOC(Block): class CustomBlockTOC(Block):
etype = "toc" etype = "toc"
def replace(self, origelement, custom_sytax_register_entry): def replace(self, origelement, custom_sytax_register_entry):
pass # Necessary information for rendering can be found in page.metadata['toc'] self.toc = None # Value will be set, after document is parsed and contentmetadata['toc'] is set.
############################## REGISTER ####################################### ############################## REGISTER #######################################
......
...@@ -312,7 +312,7 @@ ...@@ -312,7 +312,7 @@
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}
{%- macro render_block_toc(block, lang, meta) -%} {%- macro render_block_toc(block, lang, meta) -%}
{%- set toc = meta.page.metadata.toc -%} {%- set toc = block.toc -%}
<nav class="toc"> <nav class="toc">
{{ render_header(t[lang].toc.header, 2 + meta.header_level_offset, None, lang, meta.in_footer) }} {{ render_header(t[lang].toc.header, 2 + meta.header_level_offset, None, lang, meta.in_footer) }}
{{ render_toc({"children": toc}, lang, meta) }} {{ render_toc({"children": toc}, lang, meta) }}
......
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