Use GroupDocs.Markdown to convert EPUB, MOBI, and other eBook formats to clean Markdown.
Using static method
The simplest way to convert an eBook file:
importosfromgroupdocs.markdownimportLicense,MarkdownConverterdefexport_ebook_to_markdown():"""Convert an EPUB eBook to Markdown using the static one-liner API."""# Step 1: Apply the license (optional for evaluation)ifos.path.exists("GroupDocs.Markdown.lic"):License.set_("GroupDocs.Markdown.lic")# Step 2: Convert EPUB to a Markdown string in one callmarkdown=MarkdownConverter.to_markdown("business-plan.epub")# Step 3: Or save the conversion result directly to a fileMarkdownConverter.to_file("business-plan.epub","export-ebook.md")if__name__=="__main__":export_ebook_to_markdown()
business-plan.epub is sample file used in this example. Click here to download it.
HOME BASED
HOME BASED
:"""Convert an EPUB eBook to Markdown using the instance API with image export and heading offset."""# Step 1: Apply the license (optional for evaluation)ifos.path.exists("GroupDocs.Markdown.lic"):License.set_("GroupDocs.Markdown.lic")# Step 2: Open the eBook with a context managerwithMarkdownConverter("business-plan.epub")asconverter:# Step 3: Configure the image export strategy to save images to diskstrategy=ExportImagesToFileSystemStrategy("images")strategy.images_relative_path="images"# Step 4: Set conversion optionsoptions=ConvertOptions()options.image_export_strategy=strategyoptions.heading_level_offset=1# shift all headings down one level# Step # Step 5: Convert and save the Markdown outputconverter.convert("export-ebook-options.md",convert_options=options)if__name__=="__main__":export_ebook_with_options()
business-plan.epub is sample file used in this example. Click here to download it.