Skip to content

Commit b61c173

Browse files
authored
Resolved an issue with linked images in docx [mammoth] (microsoft#1405)
1 parent 80e3460 commit b61c173

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

packages/markitdown/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies = [
3636
[project.optional-dependencies]
3737
all = [
3838
"python-pptx",
39-
"mammoth",
39+
"mammoth~=1.10.0",
4040
"pandas",
4141
"openpyxl",
4242
"xlrd",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-FileCopyrightText: 2024-present Adam Fourney <adamfo@microsoft.com>
22
#
33
# SPDX-License-Identifier: MIT
4-
__version__ = "0.1.2"
4+
__version__ = "0.1.3"

packages/markitdown/src/markitdown/converters/_docx_converter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import sys
2+
import io
3+
from warnings import warn
24

35
from typing import BinaryIO, Any
46

@@ -13,6 +15,14 @@
1315
_dependency_exc_info = None
1416
try:
1517
import mammoth
18+
import mammoth.docx.files
19+
20+
def mammoth_files_open(self, uri):
21+
warn("DOCX: processing of r:link resources (e.g., linked images) is disabled.")
22+
return io.BytesIO(b"")
23+
24+
mammoth.docx.files.Files.open = mammoth_files_open
25+
1626
except ImportError:
1727
# Preserve the error and stack trace for later
1828
_dependency_exc_info = sys.exc_info()

0 commit comments

Comments
 (0)