Integrations

rtfstruct keeps integrations dependency-free in the core package. The adapter modules expose simple Python shapes that can be wrapped by MarkItDown, Docling, or Unstructured without forcing those packages on every user.

MarkItDown-Style Markdown

from rtfstruct.integrations import convert_rtf_to_markdown

markdown = convert_rtf_to_markdown(r"{\rtf1\ansi Hello}")

Docling-Style Dictionary

from rtfstruct.integrations import to_docling_dict

document = to_docling_dict(r"{\rtf1\ansi Hello}")

Unstructured-Style Partitioning

from rtfstruct.integrations import partition_rtf

elements = partition_rtf(r"{\rtf1\ansi First\par Second}")

MarkItDown-style Markdown conversion helpers.

This module does not import MarkItDown directly. It provides a tiny adapter surface that can be wrapped by a MarkItDown plugin without making MarkItDown a runtime dependency of the core library.

class rtfstruct.integrations.markitdown.RtfstructMarkdownConverter(*, parser_options=None, markdown_options=None)[source]

Small converter object suitable for wrapping in a MarkItDown plugin.

Parameters:
convert(data)[source]

Convert supported RTF input to Markdown.

Parameters:

data (bytes | str | Path | Document)

Return type:

str

rtfstruct.integrations.markitdown.convert_rtf_to_markdown(data, *, parser_options=None, markdown_options=None)[source]

Convert RTF input or an existing document AST to Markdown.

Parameters:
Return type:

str

Docling-style dictionary adapter for rtfstruct documents.

The returned dictionary is intentionally dependency-free. It preserves enough shape for downstream Docling integration experiments without importing Docling.

rtfstruct.integrations.docling.to_docling_dict(data, options=None)[source]

Convert RTF input or a document AST to a Docling-style dictionary.

Parameters:
Return type:

dict[str, object]

Unstructured-style partitioning helper for RTF documents.

This module returns plain dictionaries rather than importing unstructured. That keeps the core package dependency-free while documenting the shape needed for a future first-class partitioner.

rtfstruct.integrations.unstructured.partition_rtf(data, options=None)[source]

Partition RTF input into Unstructured-style element dictionaries.

Parameters:
Return type:

list[dict[str, object]]