Added instructions to the README.md
This commit is contained in:
parent
ef2d79e879
commit
52beb78f8a
1 changed files with 37 additions and 1 deletions
|
|
@ -5,7 +5,43 @@
|
|||
[](https://github.com/microsoft/autogen)
|
||||
|
||||
|
||||
MarkItDown Sample Plugin
|
||||
This project shows how to create a sample plugin for MarkItDown. The two most important parts are as follows:
|
||||
|
||||
First, implement you custom DocumentConverter:
|
||||
|
||||
```python
|
||||
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:
|
||||
|
||||
```toml
|
||||
[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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue