Skip to content

Commit

Permalink
Restore None check condition in HTML exporter instead of _init_resources
Browse files Browse the repository at this point in the history
Fix index.html.j2 to restore the style of the table of content.
  • Loading branch information
HaudinFlorence committed Oct 9, 2024
1 parent 711cee8 commit cdc2743
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
7 changes: 3 additions & 4 deletions nbconvert/exporters/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ def from_notebook_node( # type:ignore[explicit-override, override]
markdown_collection = markdown_collection + cell.source + "\n"

resources = self._init_resources(resources)
print('type:', resources)

if resources is None:
resources = {}
resources["tableofcontents"] = extract_titles_from_markdown_input(markdown_collection)

filter_data_type = WidgetsDataTypeFilter(
Expand Down Expand Up @@ -356,8 +356,7 @@ def resources_include_url(name):
return markupsafe.Markup(src)

resources = super()._init_resources(resources)



resources["theme"] = self.theme
resources["include_css"] = resources_include_css
resources["include_lab_theme"] = resources_include_lab_theme
Expand Down
19 changes: 10 additions & 9 deletions share/templates/lab/index.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,25 @@ a.anchor-link {
<div class="jp-RenderedHTMLTOC-Title">Table of contents</div>
{%- for item in resources.tableofcontents -%}
{%- set (level, text, id, href) = item -%}
<div
<div class="
{%- if level==1 -%}
class="jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h1"
jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h1
{%- elif level==2 -%}
class="jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h2"
jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h2
{%- elif level==3 -%}
class="jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h3"
jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h3
{%- elif level==4 -%}
class="jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h4"
jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h4
{%- elif level==5 -%}
class="jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h5"
jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h5
{%- elif level==6 -%}
class="jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h6"
{%- endif -%}
></div>
jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h6
{%- endif -%}"
>
<a href={{href}}>
{{text}}
</a>
</div>
{%- endfor -%}
{%- endif -%}
{% endblock tableofcontents %}
Expand Down

0 comments on commit cdc2743

Please sign in to comment.