Registry / data / rtfde
library0.1.2.2pypypi✓ verified 25d ago

RTFDE (RTF De-Encapsulator) is a Python library designed to extract HTML content from RTF-encapsulated HTML, a common format found within Exchange MSG email files. It provides robust parsing and de-encapsulation capabilities, focusing on raw byte input. The library is currently at version 0.1.2.2 and receives active maintenance with regular bug fixes and minor updates.

pip install rtfde
INSTALL
IMPORT
SIG · RTFDE
R
rtfde
datapythonv0.1.2.2
Install
3.2s avg
Import
135ms
Disk
40MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.140s · 41.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.2s · import 0.130s · 42MB
40MB installed
● package 40MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DeEncapsulator
from RTFDE import DeEncapsulator
from rtfde.deencapsulate import DeEncapsulator
deencapsulate
from RTFDE import deencapsulate
from rtfde.deencapsulate import deencapsulate
NullHandler
from RTFDE import NullHandler

Initialize the DeEncapsulator and pass RTF content as bytes to the `deencapsulate` method to extract the embedded HTML. The library handles the parsing and extraction of the 'htmlrtf' section.

from rtfde.deencapsulate import DeEncapsulator # Example RTF content (must be bytes) rtf_bytes = b'{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\pard\ql{\f0\fs24 Hello World!}\par\htmlrtf {\html \pard This is <b>HTML</b> content.}}' de = DeEncapsulator() html_content = de.deencapsulate(rtf_bytes) print(html_content) # Expected output: 'This is <b>HTML</b> content.'
Debug
Known issues
breakingStarting from version 0.1.0, the `deencapsulate` method strictly requires `bytes` as input. Prior versions accepted string input, which is no longer supported.
fix
Ensure all RTF input is converted to `bytes` (e.g., `my_rtf_string.encode('utf-8')`) before being passed to `DeEncapsulator.deencapsulate`.
affects: >=0.1.0
gotchaVersions of `rtfde` prior to 0.1.2.2 contained a bug (Issue #34) where invalid Unicode escape sequences within RTF byte strings could lead to parsing errors or incorrect output.
fix
Upgrade to version 0.1.2.2 or newer to benefit from the fix for invalid Unicode escape sequence handling.
affects: <0.1.2.2
gotchaThe library is designed to extract HTML from potentially complex and sometimes malformed RTF structures, especially those found in email attachments. Inputting poorly formed RTF may result in partial, incorrect, or no HTML being extracted.
fix
Implement robust error handling around `de.deencapsulate()` and validate the extracted HTML content. Consider preprocessing or sanitizing the RTF source if its integrity is frequently questionable.
affects: All versions
Upgrade
Version history
0.1.2.2latest on PyPI · released Dec 9, 2025
Audit
Dependencies
larkrequiredRequired for parsing RTF grammar.
Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources
rtfde — pip install rtfde · libregistry