Markdown flavor control

GroupDocs.Markdown supports two Markdown dialects. Set the flavor property on ConvertOptions to control the output.

GitHub Flavored Markdown (default)

GFM supports pipe tables, strikethrough text, and other extensions:

from groupdocs.markdown import MarkdownConverter, ConvertOptions, MarkdownFlavor

def flavor_github():
    """Convert a document to GitHub Flavored Markdown with pipe tables and strikethrough."""

    # Step 1: Set the Markdown flavor to GitHub (GFM)
    options = ConvertOptions()
    options.flavor = MarkdownFlavor.GIT_HUB

    # Step 2: Convert the document using keyword argument for options
    md = MarkdownConverter.to_markdown("business-plan.docx", convert_options=options)

    # Tables are rendered as:
    # | Column A | Column B |
    # | --- | --- |
    # | value1 | value2 |

if __name__ == "__main__":
    flavor_github()

business-plan.docx is sample file used in this example. Click here to download it.

CommonMark

Strict CommonMark output. Tables are rendered as fenced code blocks since CommonMark has no native table syntax:

from groupdocs.markdown import MarkdownConverter, ConvertOptions, MarkdownFlavor

def flavor_commonmark():
    """Convert a document to strict CommonMark format (no table extensions)."""

    # Step 1: Set the Markdown flavor to CommonMark
    options = ConvertOptions()
    options.flavor = MarkdownFlavor.COMMON_MARK

    # Step 2: Convert the document using keyword argument for options
    md = MarkdownConverter.to_markdown("business-plan.docx", convert_options=options)

    # Tables are rendered as fenced code blocks since CommonMark
    # has no native table syntax:
    # ```
    # Column A  |  Column B
    # value1    |  value2
    # ```

if __name__ == "__main__":
    flavor_commonmark()

business-plan.docx is sample file used in this example. Click here to download it.