diff --git a/nbconvert/exporters/templateexporter.py b/nbconvert/exporters/templateexporter.py index 0b8c27f41..da932a507 100644 --- a/nbconvert/exporters/templateexporter.py +++ b/nbconvert/exporters/templateexporter.py @@ -685,5 +685,3 @@ def _init_resources(self, resources): def include_tableofcontents(self): return True - - diff --git a/nbconvert/filters/markdown_mistune.py b/nbconvert/filters/markdown_mistune.py index c1889f06e..a79ed635e 100644 --- a/nbconvert/filters/markdown_mistune.py +++ b/nbconvert/filters/markdown_mistune.py @@ -485,6 +485,7 @@ def render(self, source: str) -> str: """Render the HTML output for a Markdown source.""" return str(super().__call__(source)) + def markdown2html_mistune(source: str) -> str: """Convert a markdown string to HTML using mistune""" return MarkdownWithMath(renderer=IPythonRenderer(escape=False)).render(source) @@ -500,6 +501,7 @@ def heading(self, text, level): self.headings.append((level, text)) return "" # We return an empty string to avoid outputting the headings + def extract_titles_from_markdown_input(markdown_input): # Markdown_input is a single string with all the markdown content concatenated # Initiate list of titles @@ -515,12 +517,15 @@ def extract_titles_from_markdown_input(markdown_input): extract_titles(markdown_input) # Extracted headings - for level, title in renderer.headings: # renderer.headings is an array for each markdown element + for ( + level, + title, + ) in renderer.headings: # renderer.headings is an array for each markdown element children = title["children"] attrs = title["attrs"] raw_text = children[0]["raw"] level = attrs["level"] - id = raw_text.replace(' ', '-') - href= "#" + id + id = raw_text.replace(" ", "-") + href = "#" + id titles_array.append([level, raw_text, id, href]) return titles_array diff --git a/share/templates/lab/index.html.j2 b/share/templates/lab/index.html.j2 index b69e7e976..0a313a72f 100644 --- a/share/templates/lab/index.html.j2 +++ b/share/templates/lab/index.html.j2 @@ -186,7 +186,7 @@ a.anchor-link { {{text}} -{%- endif -%} +{%- endif -%} {%- if level==2 -%}
diff --git a/share/templates/lab/static/index.css b/share/templates/lab/static/index.css index 08224006a..cac2fabab 100644 --- a/share/templates/lab/static/index.css +++ b/share/templates/lab/static/index.css @@ -6749,4 +6749,3 @@ div.jp-Cell-Placeholder-content-2 { div.jp-Cell-Placeholder-content-3 { top: 140px; } -