feat: add RTF (Rich Text Format) converter#2151
Open
hoangsonww wants to merge 1 commit into
Open
Conversation
Author
|
@microsoft-github-policy-service agree |
HaLaGu1L
approved these changes
Jun 22, 2026
HaLaGu1L
approved these changes
Jun 22, 2026
HaLaGu1L
approved these changes
Jun 22, 2026
HaLaGu1L
approved these changes
Jun 22, 2026
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.
Summary
Adds a converter for RTF (Rich Text Format) files, which MarkItDown did not previously support. RTF is a common interchange format (WordPad, TextEdit, legacy office exports), so this fills a real gap in the supported file types.
RtfConverteraccepts.rtffiles (the file extension and theapplication/rtf,application/x-rtf,text/rtf,text/richtextmimetypes), strips RTF control words, and returns the underlying text content as Markdown.Implementation
converters/_rtf_converter.py:RtfConverter(DocumentConverter)following the sameaccepts()/convert()shape as the existing converters. It uses the lightweight, pure-Pythonstriprtflibrary, imported lazily and gated behind the standardMissingDependencyException(matching the docx/pptx/pdf pattern), so the base install is unaffected._markitdown.pyand exported fromconverters/__init__.py.rtf = ["striprtf"]optional-dependency extra inpyproject.tomland foldedstriprtfinto[all].stream_info.charsetwith acharset-normalizerfallback).Scope
This is a v1 text-extraction converter: it preserves the document's textual content with control words removed (the same altitude as the plain-text and CSV converters). It does not attempt to map RTF bold/heading runs onto Markdown syntax, which would require a substantially heavier dependency.
Testing
tests/test_files/test.rtf(a small fixture with heading, bold, italic, and paragraph content) andtests/test_rtf_converter.py(local-path and binary-stream conversion).[all]installed (no regressions).python -m markitdown test.rtfproduces the expected Markdown.ruff checkandruff formatare clean.