Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

MarkItDown Sample Plugin

PyPI PyPI - Downloads Built by AutoGen Team

This project shows how to create a sample plugin for MarkItDown. The most important parts are as follows:

Next, implement your custom DocumentConverter:

from typing import BinaryIO, Any
from markitdown import MarkItDown, DocumentConverter, DocumentConverterResult, StreamInfo

class RtfConverter(DocumentConverter):

    def __init__(
        self, priority: float = DocumentConverter.PRIORITY_SPECIFIC_FILE_FORMAT
    ):
        super().__init__(priority=priority)

    def accepts(
        self,
        file_stream: BinaryIO,
        stream_info: StreamInfo,
        **kwargs: Any,
    ) -> bool:
	
	# Implement logic to check if the file stream is an RTF file
	# ...
	raise NotImplementedError()


    def convert(
        self,
        file_stream: BinaryIO,
        stream_info: StreamInfo,
        **kwargs: Any,
    ) -> DocumentConverterResult:

	# Implement logic to convert the file stream to Markdown
	# ...
	raise NotImplementedError()

Next, make sure your package implements and exports the following:

# The version of the plugin interface that this plugin uses. 
# The only supported version is 1 for now.
__plugin_interface_version__ = 1 

# The main entrypoint for the plugin. This is called each time MarkItDown instances are created.
def register_converters(markitdown: MarkItDown, **kwargs):
    """
    Called during construction of MarkItDown instances to register converters provided by plugins.
    """

    # Simply create and attach an RtfConverter instance
    markitdown.register_converter(RtfConverter())

Finally, create an entrypoint in the pyproject.toml file:

[project.entry-points."markitdown.plugin"]
sample_plugin = "markitdown_sample_plugin"

Here, the value of sample_plugin can be any key, but should ideally be the name of the plugin. The value is the fully qualified name of the package implementing the plugin.

Installation

To use the plugin with MarkItDown, it must be installed. To install the plugin from the current directory use:

pip install -e .

Once the plugin package is installed, verify that it is available to MarkItDown by running:

markitdown --list-plugins

To use the plugin for a conversion use the --use-plugins flag. For example, to convert an RTF file:

markitdown --use-plugins path-to-file.rtf

In Python, plugins can be enabled as follows:

from markitdown import MarkItDown

md = MarkItDown(enable_plugins=True) 
result = md.convert("path-to-file.rtf")
print(result.text_content)

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Metadata

Release files for markitdown-sample-plugin 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markitdown-sample-plugin 0.1.0a1
File Size Uploaded
markitdown_sample_plugin-0.1.0a1.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for markitdown-sample-plugin 0.1.0a1
File Interpreter ABI Platform
markitdown_sample_plugin-0.1.0a1-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / markitdown_sample_plugin-0.1.0a1.tar.gz

Download URL markitdown_sample_plugin-0.1.0a1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0628b4ef30067ebbab45733cbf46dd39457a5a9a37e095cd21cdfd5bd4fc673b
BLAKE2b-256 checksum
How to use checksums
cf6e6a88caecb93fc3044abe54193fd5f1b54de3139b8195a94e4a786066fc52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.26.0

Release files / markitdown_sample_plugin-0.1.0a1-py3-none-any.whl

Download URL markitdown_sample_plugin-0.1.0a1-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba8872e94b35cfd18f6dce626272d85baf1d406cbff3cc3efb0d4568716dfe48
BLAKE2b-256 checksum
How to use checksums
b44073b9a3c6ab8e2ba5c44f88022eaa7fb8ff728e0280e10cab18180528346f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.26.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page