From 742376ada5363db867a2c48abea6c6d8def7017b Mon Sep 17 00:00:00 2001 From: abdeladim-s Date: Thu, 19 Dec 2024 14:01:46 -0500 Subject: [PATCH] feat(DocumentConverterResult): add save method for DocumentConverterResult --- src/markitdown/_markitdown.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/markitdown/_markitdown.py b/src/markitdown/_markitdown.py index 040a586..cbd1010 100644 --- a/src/markitdown/_markitdown.py +++ b/src/markitdown/_markitdown.py @@ -146,6 +146,16 @@ class DocumentConverterResult: self.title: Union[str, None] = title self.text_content: str = text_content + def save(self, file_path: str, encoding: str = "utf-8") -> None: + """ + Save the converted document result `text_content` to a file. + + params: + file_path: The path to save the document result to. + encoding: The encoding to use when writing the document. + """ + with open(file_path, "w", encoding=encoding) as f: + f.write(self.text_content) class DocumentConverter: """Abstract superclass of all DocumentConverters."""