Skip to content

Commit 9a6c87e

Browse files
committed
fix(doc-intel): include HTML in the default DocumentIntelligenceConverter file types
The constructor documents file_types as "Defaults to all supported file types", but the default list has never contained DocumentIntelligenceFileType.HTML, even though the enum lists it under "# No OCR" and _get_mime_type_prefixes / _get_file_extensions / _analysis_features all handle it. So accepts() rejects .html, text/html and application/xhtml+xml unless the caller passes file_types explicitly. The HTML mappings added in #1352 are unreachable through the default constructor, and MarkItDown never passes file_types when it builds the converter from docintel_endpoint.
1 parent fd239d5 commit 9a6c87e

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

packages/markitdown/src/markitdown/converters/_doc_intel_converter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def __init__(
140140
DocumentIntelligenceFileType.DOCX,
141141
DocumentIntelligenceFileType.PPTX,
142142
DocumentIntelligenceFileType.XLSX,
143+
DocumentIntelligenceFileType.HTML,
143144
DocumentIntelligenceFileType.PDF,
144145
DocumentIntelligenceFileType.JPEG,
145146
DocumentIntelligenceFileType.PNG,
@@ -251,4 +252,4 @@ def convert(
251252

252253
# remove comments from the markdown content generated by Doc Intelligence and append to markdown string
253254
markdown_text = re.sub(r"<!--.*?-->", "", result.content, flags=re.DOTALL)
254-
return DocumentConverterResult(markdown=markdown_text)
255+
return DocumentConverterResult(markdown=markdown_text)

packages/markitdown/tests/test_docintel_html.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import inspect
12
import io
23
from markitdown.converters._doc_intel_converter import (
34
DocumentIntelligenceConverter,
@@ -6,6 +7,11 @@
67
from markitdown._stream_info import StreamInfo
78

89

10+
def _default_file_types():
11+
params = inspect.signature(DocumentIntelligenceConverter.__init__).parameters
12+
return params["file_types"].default
13+
14+
915
def _make_converter(file_types):
1016
conv = DocumentIntelligenceConverter.__new__(DocumentIntelligenceConverter)
1117
conv._file_types = file_types
@@ -24,3 +30,19 @@ def test_docintel_accepts_html_mimetype():
2430
assert conv.accepts(io.BytesIO(b""), stream_info)
2531
stream_info = StreamInfo(mimetype="application/xhtml+xml", extension=None)
2632
assert conv.accepts(io.BytesIO(b""), stream_info)
33+
34+
35+
def test_docintel_default_file_types_cover_every_supported_type():
36+
# The file_types docstring promises "Defaults to all supported file types",
37+
# so the default must stay in sync with the enum.
38+
assert set(_default_file_types()) == set(DocumentIntelligenceFileType)
39+
40+
41+
def test_docintel_default_accepts_html():
42+
conv = _make_converter(_default_file_types())
43+
for stream_info in (
44+
StreamInfo(mimetype=None, extension=".html"),
45+
StreamInfo(mimetype="text/html", extension=None),
46+
StreamInfo(mimetype="application/xhtml+xml", extension=None),
47+
):
48+
assert conv.accepts(io.BytesIO(b""), stream_info)

0 commit comments

Comments
 (0)