Beispiel #1
0
def convert_markdown(markdown_source):
    """
    Convert the Markdown source file to HTML content, and additionally
    return the parsed table of contents, and a dictionary of any metadata
    that was specified in the Markdown file.
    """

    # Prepend a table of contents marker for the TOC extension
    markdown_source = toc.pre_process(markdown_source)

    # Generate the HTML from the markdown source
    md = markdown.Markdown(extensions=['meta', 'toc', 'tables', 'fenced_code'])
    html_content = md.convert(markdown_source)
    meta = md.Meta

    # Strip out the generated table of contents
    (html_content, toc_html) = toc.post_process(html_content)

    # Post process the generated table of contents into a data structure
    table_of_contents = toc.TableOfContents(toc_html)

    return (html_content, table_of_contents, meta)
Beispiel #2
0
def convert_markdown(markdown_source):
    """
    Convert the Markdown source file to HTML content, and additionally
    return the parsed table of contents, and a dictionary of any metadata
    that was specified in the Markdown file.
    """

    # Prepend a table of contents marker for the TOC extension
    markdown_source = toc.pre_process(markdown_source)

    # Generate the HTML from the markdown source
    md = markdown.Markdown(extensions=['meta', 'toc', 'tables', 'fenced_code'])
    html_content = md.convert(markdown_source)
    meta = md.Meta

    # Strip out the generated table of contents
    (html_content, toc_html) = toc.post_process(html_content)

    # Post process the generated table of contents into a data structure
    table_of_contents = toc.TableOfContents(toc_html)

    return (html_content, table_of_contents, meta)
Beispiel #3
0
 def markdown_to_toc(self, markdown_source):
     markdown_source = toc.pre_process(markdown_source)
     md = markdown.Markdown(extensions=['toc'])
     html_output = md.convert(markdown_source)
     html_output, toc_output = toc.post_process(html_output)
     return toc.TableOfContents(toc_output)
Beispiel #4
0
 def markdown_to_toc(self, markdown_source):
     markdown_source = toc.pre_process(markdown_source)
     md = markdown.Markdown(extensions=['toc'])
     html_output = md.convert(markdown_source)
     html_output, toc_output = toc.post_process(html_output)
     return toc.TableOfContents(toc_output)