feat: add DocConverter for legacy .doc (Word 97-2003) files#1710
Open
AviArora02-commits wants to merge 1 commit intomicrosoft:mainfrom
Open
feat: add DocConverter for legacy .doc (Word 97-2003) files#1710AviArora02-commits wants to merge 1 commit intomicrosoft:mainfrom
AviArora02-commits wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Closes microsoft#23 Adds DocConverter using olefile to parse OLE Compound Document format. Reads FIB from WordDocument stream, locates PlcPcd piece table in the table stream, decodes each piece as CP1252 or UTF-16LE. Falls back to UTF-16 brute-scan for corrupted documents. No new dependencies - olefile is already used by OutlookMsgConverter.
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #23
Add support for legacy
.doc(Word 97-2003) files — Closes #23Summary
This PR adds a new
DocConverterthat converts legacy Microsoft Word.docfiles(Word 97–2003 OLE Compound Document format) to Markdown, closing issue #23.
# All of these now work: markitdown document.docWhat changed
converters/_doc_converter.pyDocConverterclassconverters/__init__.pyDocConverter_markitdown.pyDocConverterpyproject.tomldoc = ["olefile"]optional dependency grouptests/_test_vectors.pyFileTestVectorfortest.doctests/test_files/test.docTechnical approach
The legacy
.docformat is an OLE Compound Document (the same container usedby Outlook
.msgfiles, which markitdown already handles viaolefile).No new third-party dependencies are introduced —
olefileis already inpyproject.tomlas an optional dependency forOutlookMsgConverter.The converter follows the Word97-2007 Binary File Format spec:
olefile.OleFileIO.WordDocumentstreamto locate the CLX (piece table container) in either
0Tableor1Table.PlcPcd(piece table).(two bytes/char), preserving paragraph breaks (
\r→\n).(handles corrupted or fast-saved documents).
Limitations (documented in the class docstring)
Rich formatting (bold, italic, heading styles, tables) is not preserved.
The legacy binary format requires a full Word parser to reconstruct that
information. Plain text extraction is what LLM pipelines need anyway, and
it keeps the implementation minimal and dependency-free.
Users who need rich formatting from modern Word files should use
.docx(already supported by
DocxConverterviamammoth).Testing
The new
test.docfixture contains two known UUIDs that the test vectorchecks for, following the same pattern as the existing
.docxtest.Install
pr_description.md