Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def convert(
result = self._markitdown.convert_stream(
stream=z_file_stream,
stream_info=z_file_stream_info,
**kwargs,
)
if result is not None:
md_content += f"## File: {name}\n\n"
Expand Down
20 changes: 20 additions & 0 deletions packages/markitdown/tests/test_module_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import shutil
import zipfile
import pytest
from unittest.mock import MagicMock

Expand Down Expand Up @@ -220,6 +221,25 @@ def test_data_uris() -> None:
assert data == b"Hello, World!"


def test_zip_conversion_propagates_keep_data_uris() -> None:
archive = io.BytesIO()
html = (
"<html><body><img alt='example' "
"src='data:image/png;base64,SGVsbG8='></body></html>"
)
with zipfile.ZipFile(archive, "w") as zf:
zf.writestr("index.html", html)
archive.seek(0)

result = MarkItDown().convert_stream(
archive,
stream_info=StreamInfo(extension=".zip", mimetype="application/zip"),
keep_data_uris=True,
)

assert "data:image/png;base64,SGVsbG8=" in result.markdown


def test_file_uris() -> None:
# Test file URI with an empty host
file_uri = "file:///path/to/file.txt"
Expand Down