microsoft / microsoft/markitdown

[Enhancement] Override Converters Priority

Open
#1,244 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
186k
Forks
13.7k
Avg merge
1d 4h
Merged PRs (30d)
49

Description

Problem

Currently, you can assign priority to your plugin while development and assign a lower value to execute the plugin before built-in. The current version of the library doesn't support passing priority for converters manually.

Solution

The idea is to pass priority values manually when instantiating the MarkItDown class.

In my case, I am building a plugin with multiple converters, and I would like them to execute in different orders based on use case.

A simple change to the MarkItDown class can achieve this

Changes to class
class MarkItDown:
    def __init__(
        self,
        *,
        enable_builtins: Union[None, bool] = None,
        enable_plugins: Union[None, bool] = None,
        **kwargs,
    ):
        self._builtins_enabled = False
        self._plugins_enabled = False
        
        # Store converter priorities from kwargs
        self._converter_priorities = kwargs.get("converter_priorities", {})
Changes to register_converter method
    def register_converter(
        self,
        converter: DocumentConverter,
        *,
        priority: float = PRIORITY_SPECIFIC_FILE_FORMAT,
    ) -> None:

        # If priority is defined, then override for the converter
        converter_type = type(converter).__name__
        if converter_type in self._converter_priorities:
            priority = self._converter_priorities[converter_type]
            
        self._converters.insert(
            0, ConverterRegistration(converter=converter, priority=priority)
        )

Now, the priorities can be passed as an Argument to MarkItDown class allowing flexibility in execution order. If approved, please assign this issue to me—I can submit a PR to implement this enhancement. Thank you!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the MarkItDown class, especially init and register_converter, and trace how converter registrations are ordered. Confirm the intended priority override behavior for converters supplied through converter_priorities; the work is done when converters execute in the requested order without changing the existing defaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.