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:
fromgroupdocs.markdownimportMarkdownConverter,ConvertOptions,MarkdownFlavordefflavor_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 optionsmd=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:
fromgroupdocs.markdownimportMarkdownConverter,ConvertOptions,MarkdownFlavordefflavor_commonmark():"""Convert a document to strict CommonMark format (no table extensions)."""# Step 1: Set the Markdown flavor to CommonMarkoptions=ConvertOptions()options.flavor=MarkdownFlavor.COMMON_MARK# Step 2: Convert the document using keyword argument for optionsmd=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.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.