Skip to content

fix(docx): clamp Word Heading 7-9 to markdown h6 - #2531

Closed
Manohar Paturi (ManoharPaturi) wants to merge 2 commits into
microsoft:mainfrom
ManoharPaturi:fix/docx-deep-heading-levels
Closed

Manohar Paturi (ManoharPaturi) wants to merge 2 commits into
microsoft:mainfrom
ManoharPaturi:fix/docx-deep-heading-levels

Conversation

@ManoharPaturi

Copy link
Copy Markdown

Fixes #2530.

Adds style-map entries so Word Heading 7/8/9 clamp to markdown h6 instead of rendering as plain paragraphs. One regression test covering levels 1-9 (fails on main where 7-9 lose their heading).

MarkItDown._convert applied its whitespace cleanup (rstrip every line,
collapse 3+ newlines to 2) to the entire converted document, which
corrupted fenced code blocks: blank-line runs inside a fence collapsed
and trailing spaces were stripped, changing code content. Track code
fences while normalizing and leave their contents untouched.

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
mammoth's default style map stops at Heading 6, so Word's deeper heading
styles came through as plain paragraphs and their structure was dropped.
Add style-map entries mapping Heading 7/8/9 to h6, the deepest level
markdown supports.

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 18, 2026 12:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ManoharPaturi

Copy link
Copy Markdown
Author

XU (@kokokoXUY) same stacking issue here as on #2533, rebuilt from current main so the diff is only the docx heading clamp and its test (4121d96, single commit). the whitespace and xlsx changes live in their own PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOCX: Heading 7-9 styles lose heading structure entirely (render as plain paragraphs)

2 participants