Python tool for converting files and office documents to Markdown.
Added support to use Pathlib (#93)
SigireddyBalasai5276616ba147
diff --git a/src/markitdown/_markitdown.py b/src/markitdown/_markitdown.pyindex 040a586e..789c1e55 100644--- a/src/markitdown/_markitdown.py+++ b/src/markitdown/_markitdown.py@@ -15,6 +15,7 @@ import tracebackimport zipfilefrom xml.dom import minidomfrom typing import Any, Dict, List, Optional, Union+from pathlib import Pathfrom urllib.parse import parse_qs, quote, unquote, urlparse, urlunparsefrom warnings import warn, resetwarnings, catch_warnings@@ -1286,11 +1287,11 @@ class MarkItDown:self.register_page_converter(ZipConverter())def convert(- self, source: Union[str, requests.Response], **kwargs: Any+ self, source: Union[str, requests.Response, Path], **kwargs: Any) -> DocumentConverterResult: # TODO: deal with kwargs"""Args:- - source: can be a string representing a path or url, or a requests.response object+ - source: can be a string representing a path either as string pathlib path object or url, or a requests.response object- extension: specifies the file extension to use when interpreting the file. If None, infer from source (path, uri, content-type, etc.)"""@@ -1307,10 +1308,14 @@ class MarkItDown:# Request responseelif isinstance(source, requests.Response):return self.convert_response(source, **kwargs)+ elif isinstance(source, Path):+ return self.convert_local(source, **kwargs)def convert_local(- self, path: str, **kwargs: Any+ self, path: Union[str, Path], **kwargs: Any) -> DocumentConverterResult: # TODO: deal with kwargs+ if isinstance(path, Path):+ path = str(path)# Prepare a list of extensions to try (in order of priority)ext = kwargs.get("file_extension")extensions = [ext] if ext is not None else []