Skip to content

feat: add option to include DOCX comments - #2322

Open
garlic9912 wants to merge 1 commit into
microsoft:mainfrom
garlic9912:feat/docx-include-comments
Open

feat: add option to include DOCX comments#2322
garlic9912 wants to merge 1 commit into
microsoft:mainfrom
garlic9912:feat/docx-include-comments

Conversation

@garlic9912

@garlic9912 garlic9912 commented Aug 20, 2026

Copy link
Copy Markdown

What this changes

This adds an include_comments option for DOCX files:

result = md.convert("review.docx", include_comments=True)

There is also a CLI flag:

markitdown review.docx --include-comments

Mammoth already knows how to convert Word comments, but it requires the following style-map rule:

comment-reference =>

So this PR mainly makes that existing behavior easier to discover and use.

Comments are still excluded by default because changing the default would change the output for existing users. Comments can also contain internal review notes and add quite a lot of extra text.

If the user provides a custom style_map, it is kept and the comment rule is appended to it. User rules come first, so a custom comment-reference rule still takes priority.

I kept Mammoth's existing comment links and backlinks instead of converting them to Markdown footnotes. Footnotes would need extra decisions around Markdown dialects, existing footnotes, repeated references, tables, and backlinks. That felt outside the scope of this change.

The tests cover:

  • comments disabled by default;
  • enabling comments per conversion or on MarkItDown;
  • overriding the constructor option for one conversion;
  • multiple comments and their links/backlinks;
  • comments inside normal text and tables;
  • combining comments with a custom style_map;
  • the new CLI flag.

Closes #2275.

@garlic9912

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

Feature request: Possibility to include comments of docx into md file

1 participant