Skip to content

Commit

Permalink
Updates jinja templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaudinFlorence committed Sep 16, 2024
1 parent e364a11 commit f7eb4c4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
8 changes: 3 additions & 5 deletions nbconvert/exporters/templateexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,7 @@ def _init_resources(self, resources):
resources["include_tableofcontents"] = self.include_tableofcontents
return resources

def include_tableofcontents(self, resources):
# if len(resources["tableofcontents"])>0:
def include_tableofcontents(self):
return True

# else:
# return False


3 changes: 2 additions & 1 deletion share/templates/base/null.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ calling super.
consider calling super even if it is a leaf block, we might insert more blocks later.
#}
{%- block header -%}
{%- endblock header -%}
{%- block body -%}
{%- block body_header -%}
<div>{{"Hello \n\"World\""}}</div>
{%- endblock body_header -%}
{%- block body_loop -%}
{%- for cell in nb.cells -%}
Expand Down
5 changes: 2 additions & 3 deletions share/templates/lab/base.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
{% from 'celltags.j2' import celltags %}
{% from 'cell_id_anchor.j2' import cell_id_anchor %}

{% block tableofcontents %}
<div> {{"Table of contents"}} </div>
{%- block body_header -%}
{%- endblock body_header -%}

{% endblock tableofcontents %}

{% block codecell %}
{%- if not cell.outputs -%}
Expand Down
22 changes: 22 additions & 0 deletions share/templates/lab/index.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,28 @@ a.anchor-link {
<body class="jp-Notebook" data-jp-theme-light="true" data-jp-theme-name="JupyterLab Light">
{% endif %}
<main>
{%- for item in resources.tableofcontents -%}
{%- set (level, text) = item -%}
{%- if level==1 -%}
<h1>{{text}}</h1>
{%- endif -%}
{%- if level==2 -%}
<h2>{{text}}</h2>
{%- endif -%}
{%- if level==3 -%}
<h3>{{text}}</h3>
{%- endif -%}
{%- if level==4 -%}
<h4>{{text}}</h4>
{%- endif -%}
{%- if level==5 -%}
<h5>{{text}}</h5>
{%- endif -%}
{%- if level==6 -%}
<h6>{{text}}</h6>
{%- endif -%}
{%- endfor -%}

{%- endblock body_header -%}

{% block body_footer %}
Expand Down

0 comments on commit f7eb4c4

Please sign in to comment.