Skip to content

Commit aa7c725

Browse files
committed
test: cover partition_md processing-instruction path (#4358)
The markdown entry path routes through the same HTML parser, so add a regression test that exercises partition_md directly with a <?xml ?> PI.
1 parent 0157bb6 commit aa7c725

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

test_unstructured/partition/test_md.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ def test_partition_md_from_text():
4343
assert all(e.metadata.filename is None for e in elements)
4444

4545

46+
def test_partition_md_ignores_processing_instructions():
47+
"""A processing-instruction like `<?xml ...?>` must not crash partition_md (see #4358)."""
48+
elements = partition_md(text='Before\n\n<?xml version="1.0"?>\n\nAfter')
49+
50+
texts = [e.text for e in elements]
51+
assert "Before" in texts
52+
assert "After" in texts
53+
54+
4655
class MockResponse:
4756
def __init__(self, text: str, status_code: int, headers: dict[str, Any] = {}):
4857
self.text = text

0 commit comments

Comments
 (0)