markitdown/packages/markitdown-sample-plugin
2025-02-10 00:25:23 -08:00
..
src/markitdown_sample_plugin Added sample plugin. 2025-02-10 00:13:17 -08:00
tests Added sample plugin. 2025-02-10 00:13:17 -08:00
pyproject.toml Added sample plugin. 2025-02-10 00:13:17 -08:00
README.md Added instructions to the README.md 2025-02-10 00:25:23 -08:00

MarkItDown Sample Plugin

PyPI PyPI - Downloads Built by AutoGen Team

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

First, implement you custom DocumentConverter:

from typing import Union
from markitdown import DocumentConverter, DocumentConverterResult


class RtfConverter(DocumentConverter):
    def convert(self, local_path, **kwargs) -> Union[None, DocumentConverterResult]:
        # Bail if not an RTF file 
        extension = kwargs.get("file_extension", "")
        if extension.lower() != ".rtf":
            return None

	# Implement the conversion logic here ...

        # Return the result
        return DocumentConverterResult(
            title=title,
            text_content=text_content,
        )

Second, you create an entrypoint in the pyproject.toml file:

[project.entry-points."markitdown.plugin.converters"]
rtf = "markitdown_sample_plugin:RtfConverter"

Here, the value of rtf can be any key, but should ideally be the name of the plugin, or the extension it supports. The value is the fully qualified name of the class that implements the DocumentConverter interface.

Once the plugin package is installed (e.g., pip install -e .), MarkItDown will automatically discover the plugin and register it for use.

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.