markitdown icon indicating copy to clipboard operation
markitdown copied to clipboard

Nested list in docx is not properly parsed in Markdown

Open org30h opened this issue 3 months ago • 1 comments

Description

When a word document contains nested lists like

1. Item 1
2. Item 2
   • Item 2.1
   • Item 2.2
3. Item 3
   a) Item 3.1
   b) Item 3.2

The output markdown will be wrongly rendered without the nested numbered list as:

1. Item 1
2. Item 2
   * Item 2.1
   * Item 2.2
3. Item 3
4. Item 3.1
5. Item 3.2

Reproduce

Original docx file to reproduce the bug: MarkItDown_MultiListBug_test.docx

Image

Markdown output: output.md

Image

org30h avatar Aug 21 '26 05:08 org30h

I isolated the attachment to the two paragraphs Item 3 and Item 3.1. The flattening is already present in the intermediate Mammoth HTML:

<ol><li>Item 3</li><li>Item 3.1</li></ol>

Both paragraphs have w:ilvl=0, but Item 3 uses numId=1 and Item 3.1 uses a separate numId=3 definition with lower-letter numbering. Their numbering definitions use left indents of 720 and 1080 twips respectively. This seems useful when investigating how the visual nesting in the screenshot should map to semantic nesting; the loss happens before HTML-to-Markdown conversion.

Confirmed with the released MarkItDown 0.1.8 dependency set (Mammoth 1.11.0, markdownify 1.2.3) in a fresh environment, and also with the current checkout plus Mammoth 1.13.0.

I maintain docx-repro, which I used for the reduction. The checker requires both paragraphs and their numbering properties to remain, then confirms the same unindented numbered output. It reduced 8 paragraphs to 2 and preserved the payloads of the other package parts. Checker and reproduction details.

The result narrows the reproduction; it does not establish the correct nesting rule or fix the issue. The original attachment is linked in the case study and is not redistributed.

capt1nedev avatar Oct 07 '26 10:10 capt1nedev