@@ -385,7 +385,7 @@ def _embed_image_or_attachment(self, src: str) -> str:
385385
386386 attachment_prefix = "attachment:"
387387 if src .startswith (attachment_prefix ):
388- name = src [len (attachment_prefix ) :]
388+ name = src [len (attachment_prefix ):]
389389
390390 if name not in self .attachments :
391391 msg = f"missing attachment: { name } "
@@ -485,6 +485,7 @@ def render(self, source: str) -> str:
485485 """Render the HTML output for a Markdown source."""
486486 return str (super ().__call__ (source ))
487487
488+
488489def markdown2html_mistune (source : str ) -> str :
489490 """Convert a markdown string to HTML using mistune"""
490491 return MarkdownWithMath (renderer = IPythonRenderer (escape = False )).render (source )
@@ -500,6 +501,7 @@ def heading(self, text, level):
500501 self .headings .append ((level , text ))
501502 return "" # We return an empty string to avoid outputting the headings
502503
504+
503505def extract_titles_from_markdown_input (markdown_input ):
504506 # Markdown_input is a single string with all the markdown content concatenated
505507 # Initiate list of titles
@@ -515,12 +517,12 @@ def extract_titles_from_markdown_input(markdown_input):
515517 extract_titles (markdown_input )
516518
517519 # Extracted headings
518- for level , title in renderer .headings : # renderer.headings is an array for each markdown element
520+ for level , title in renderer .headings :
519521 children = title ["children" ]
520522 attrs = title ["attrs" ]
521523 raw_text = children [0 ]["raw" ]
522524 level = attrs ["level" ]
523525 id = raw_text .replace (' ' , '-' )
524- href = "#" + id
526+ href = "#" + id
525527 titles_array .append ([level , raw_text , id , href ])
526528 return titles_array
0 commit comments