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 and save it to a Markdown fileMarkdownConverter.to_file("business-plan.docx","flavor-github.md",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.
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 and save it to a Markdown fileMarkdownConverter.to_file("business-plan.docx","flavor-commonmark.md",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.