Skip to main content

A sample plugin for the "markitdown" library.

Project description

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:

FNext, implement your 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,
        )

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.

Once the plugin package is installed (e.g., pip install -e .), MarkItDown will automatically discover 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markitdown_sample_plugin-0.0.1a2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markitdown_sample_plugin-0.0.1a2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file markitdown_sample_plugin-0.0.1a2.tar.gz.

File metadata

File hashes

Hashes for markitdown_sample_plugin-0.0.1a2.tar.gz
Algorithm Hash digest
SHA256 7a732c80c307f9b329356ebf3e9bf95bfdd16ff5cf2c15d998c72f319deceac1
MD5 2c1290dcae1535e10562e41a92297d29
BLAKE2b-256 6f538b2dc50db78f61a572579831c158f16b354a3c92e8a2eb28f55c52875fdd

See more details on using hashes here.

File details

Details for the file markitdown_sample_plugin-0.0.1a2-py3-none-any.whl.

File metadata

File hashes

Hashes for markitdown_sample_plugin-0.0.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 90622df45467006726c02fb2458ce114af4373f0a9ba63e0cd416ab473d46504
MD5 ecbfe5686d8986806c0304c8d645623a
BLAKE2b-256 118fdee5e457add9a6235ad1b65616c71397e554e44035742efd8b92fe0c74f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page