Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openkb/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def convert_document(
markdown = convert_pdf_with_images(src, doc_name, images_dir)
else:
# Non-PDF, non-MD: use markitdown (docx, pptx, html, etc.)
mid = MarkItDown(keep_data_uris=True)
result = mid.convert(str(src))
mid = MarkItDown()
result = mid.convert(str(src), keep_data_uris=True)
markdown = result.text_content
markdown = extract_base64_images(markdown, doc_name, images_dir)

Expand Down
9 changes: 6 additions & 3 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ def test_docx_conversion_enables_keep_data_uris(self, kb_dir, tmp_path):

with (
patch("openkb.converter.MarkItDown") as mock_markitdown,
patch("openkb.converter.extract_base64_images", return_value="converted markdown") as mock_extract,
patch(
"openkb.converter.extract_base64_images",
return_value="converted markdown",
) as mock_extract,
):
mock_markitdown.return_value.convert.return_value = mock_result

result = convert_document(src, kb_dir)

mock_markitdown.assert_called_once_with(keep_data_uris=True)
mock_markitdown.return_value.convert.assert_called_once_with(str(src))
mock_markitdown.assert_called_once_with()
mock_markitdown.return_value.convert.assert_called_once_with(str(src), keep_data_uris=True)
mock_extract.assert_called_once()
assert result.skipped is False
assert result.is_long_doc is False
Expand Down
Loading