Skip to content

Python tool for converting files and office documents to Markdown.

Fixed loading of plugins. (#1096)

afourney938011289277
diff --git a/packages/markitdown-sample-plugin/pyproject.toml b/packages/markitdown-sample-plugin/pyproject.toml
index a12b9aac..400cc4f2 100644
--- a/packages/markitdown-sample-plugin/pyproject.toml
+++ b/packages/markitdown-sample-plugin/pyproject.toml
@@ -24,7 +24,7 @@ classifiers = [
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
- "markitdown>=0.2.0a1",
+ "markitdown>=0.2.0a2",
"striprtf",
]
diff --git a/packages/markitdown-sample-plugin/src/markitdown_sample_plugin/__about__.py b/packages/markitdown-sample-plugin/src/markitdown_sample_plugin/__about__.py
index ca1bba50..f691daf9 100644
--- a/packages/markitdown-sample-plugin/src/markitdown_sample_plugin/__about__.py
+++ b/packages/markitdown-sample-plugin/src/markitdown_sample_plugin/__about__.py
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-present Adam Fourney <[email protected]>
#
# SPDX-License-Identifier: MIT
-__version__ = "0.2.0a1"
+__version__ = "0.2.0a2"
diff --git a/packages/markitdown/src/markitdown/__about__.py b/packages/markitdown/src/markitdown/__about__.py
index ca1bba50..f691daf9 100644
--- a/packages/markitdown/src/markitdown/__about__.py
+++ b/packages/markitdown/src/markitdown/__about__.py
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-present Adam Fourney <[email protected]>
#
# SPDX-License-Identifier: MIT
-__version__ = "0.2.0a1"
+__version__ = "0.2.0a2"
diff --git a/packages/markitdown/src/markitdown/_markitdown.py b/packages/markitdown/src/markitdown/_markitdown.py
index 6086eb9a..d88bb73c 100644
--- a/packages/markitdown/src/markitdown/_markitdown.py
+++ b/packages/markitdown/src/markitdown/_markitdown.py
@@ -58,10 +58,10 @@ PRIORITY_GENERIC_FILE_FORMAT = (
)
-_plugins: List[Any] = []
+_plugins: Union[None, List[Any]] = None # If None, plugins have not been loaded yet.
-def _load_plugins() -> List[Any]:
+def _load_plugins() -> Union[None, List[Any]]:
"""Lazy load plugins, exiting early if already loaded."""
global _plugins
@@ -186,7 +186,9 @@ class MarkItDown:
"""
if not self._plugins_enabled:
# Load plugins
- for plugin in _load_plugins():
+ plugins = _load_plugins()
+ assert plugins is not None
+ for plugin in plugins:
try:
plugin.register_converters(self, **kwargs)
except Exception: