コード例 #1
0
ファイル: build.py プロジェクト: sampsyo/mkdocs
def convert_markdown(markdown_source, extensions=()):
    """
    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.

    `extensions` is an optional sequence of Python Markdown extensions to add
    to the default set.
    """

    # 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'] + list(extensions)
    )
    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)
コード例 #2
0
def convert_markdown(markdown_source, extensions=()):
    """
    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.

    `extensions` is an optional sequence of Python Markdown extensions to add
    to the default set.
    """

    # 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'] + list(extensions)
    )
    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)
コード例 #3
0
ファイル: build.py プロジェクト: vanzaj/mkdocs
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', 'codehilite(pygments_style=borland)'])
    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)
コード例 #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)
コード例 #5
0
ファイル: test.py プロジェクト: alihalabyah/mkdocs
 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)