Use heading_level_offset to shift all heading levels in the output by a fixed number. This is useful when embedding converted content inside a larger document where top-level headings are already in use.
Example
fromgroupdocs.markdownimportMarkdownConverter,ConvertOptionsdefheading_offset_example():"""Shift all heading levels by a fixed offset when converting to Markdown."""# Step 1: Set the heading level offset to 2options=ConvertOptions()options.heading_level_offset=2# shift all headings down two levels# Step 2: Convert the document using keyword argument for optionsmd=MarkdownConverter.to_markdown("annual-report.docx",convert_options=options)# Source: # Title -> Output: ### Title# Source: ## Section -> Output: #### Section# Heading levels are clamped to the range 1-6.if__name__=="__main__":heading_offset_example()
annual-report.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.