From cdc2743cfc69399e3621c79fa1587c17a499f0b9 Mon Sep 17 00:00:00 2001 From: HaudinFlorence Date: Wed, 9 Oct 2024 10:01:51 +0200 Subject: [PATCH] Restore None check condition in HTML exporter instead of _init_resources Fix index.html.j2 to restore the style of the table of content. --- nbconvert/exporters/html.py | 7 +++---- share/templates/lab/index.html.j2 | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/nbconvert/exporters/html.py b/nbconvert/exporters/html.py index 523ea44dd..c6f10418e 100644 --- a/nbconvert/exporters/html.py +++ b/nbconvert/exporters/html.py @@ -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( @@ -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 diff --git a/share/templates/lab/index.html.j2 b/share/templates/lab/index.html.j2 index a9cb94ae9..20b2eaae1 100644 --- a/share/templates/lab/index.html.j2 +++ b/share/templates/lab/index.html.j2 @@ -181,24 +181,25 @@ a.anchor-link {
Table of contents
{%- for item in resources.tableofcontents -%} {%- set (level, text, id, href) = item -%} -
+jp-RenderedHTMLCommon jp-RenderedHTMLTOC-Item-h6 +{%- endif -%}" +> {{text}} + {%- endfor -%} {%- endif -%} {% endblock tableofcontents %}