Repository navigation
Description
Summary
Atom entries with content type="text" are passed through the HTML parser, which silently removes tag-shaped plain text and decodes entity-like strings a second time. This also affects summary and entries where type is omitted.
For example, the original plain text Run <job_id> with <literal>. becomes Run with <literal>. in the Markdown source. Losing identifiers or placeholders can change content subsequently consumed by search or LLM pipelines.
Environment
- Source checkout:
cfe54d24cc45f66d43a54073c2d0f821f49ecb92, currentmainwhen tested on 2026-09-04. - Editable package reports
markitdown==0.1.7; this report tests the commit above, not a separately installed PyPI release. - Python 3.11.15, macOS 26.5.2 arm64.
beautifulsoup4==4.15.0,markdownify==1.2.3,defusedxml==0.7.1.
Minimal reproduction
Install the source snapshot in a disposable virtual environment:
python -m pip install "markitdown @ git+https://github.com/microsoft/markitdown.git@cfe54d24cc45f66d43a54073c2d0f821f49ecb92#subdirectory=packages/markitdown" "beautifulsoup4==4.15.0" "markdownify==1.2.3" "defusedxml==0.7.1"Then run:
from io import BytesIO
from markitdown import MarkItDown, StreamInfo
feed = b'''<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example feed</title>
<id>urn:example:feed</id>
<updated>2026-09-04T00:00:00Z</updated>
<author><name>Example author</name></author>
<entry>
<title>Example entry</title>
<id>urn:example:entry</id>
<updated>2026-09-04T00:00:00Z</updated>
<content type="text">Run <job_id> with &lt;literal&gt;.</content>
</entry>
</feed>'''
result = MarkItDown(enable_plugins=False).convert_stream(
BytesIO(feed),
stream_info=StreamInfo(extension=".atom", mimetype="application/atom+xml"),
)
print(result.markdown.splitlines()[-1])
assert "job" in result.markdown, "Plain-text identifier was silently lost"Actual output, followed by AssertionError:
Run with <literal>.
Expected: preserve the original readable text below, with appropriate Markdown escaping:
Run <job_id> with <literal>.
This does not require one exact Markdown serialization. Even the identifier letters are missing from the actual output.
Why this appears incorrect
RFC 4287 §4.1.3.1–3 distinguishes plain text from HTML and defines omitted inline content type as text. The corresponding text-construct rules apply to summaries.
In _rss_converter.py, _get_atom_content preserves the XHTML distinction but returns both text and HTML as untyped strings. _parse_atom_type then passes both through _parse_content, where BeautifulSoup interprets the already XML-decoded plain text as HTML.
Validation and possible direction
- Reproduced through both
RssConverter.convertand the publicMarkItDown.convert_streamAPI. - Eight regression cases fail: two APIs × content/summary × explicit/default text type.
- Six controls pass: ordinary plain text and HTML/XHTML conversion through both APIs.
- The existing
tests/test_rss_converter.pypasses all three tests. - These use small synthetic in-memory fixtures only; no model APIs or real user documents are involved.
Could text/default-text retain their type through extraction and take a Markdown-escaping-aware plain-text path, while HTML/XHTML keep their existing conversion? Simply returning unescaped raw text may introduce other Markdown interpretation problems, so angle brackets, ampersands, asterisks, underscores, links, and backslashes deserve regression coverage.
Related: #2297 fixes XHTML child content; this report concerns the separate plain-text path. Searches for atom, rss, and atom text, plus related PR inspection, did not reveal an exact existing report at review time.
AI-assistance disclosure: this report and its fixtures were prepared with AI assistance, and the reproduction and focused tests were executed locally against the unmodified source checkout.
Activity
afourney commentedon Sep 3, 2026
李俊祎 (@17lijunyi) what is your use case? #2374 is now merged to main, and passes text content through without modification (other than strip and detent). If the text content contains markdown characters (e.g., "# " or "**", then these are not escaped in the output). Does this work for you?
Chirag6722 commentedon Sep 4, 2026
I hit this thread while looking for something to work on, so I checked whether it still reproduces on
main— Adam Fourney (@afourney)'s question above hadn't been answered and it seemed worth settling with a run rather than leaving it open.It is fixed. On
4459ed0(currentmain), the reproduction from the issue prints exactly what it lists as expected:The identifier survives and the entity is not decoded a second time, so #2374 covers the case as filed.
I also ran the two variants the issue mentions but does not show, since a fix that covered only the headline case would leave the report half-true:
content type="text"Run <job_id> with <literal>.content, notypeRun <job_id> with <literal>.summary type="text"Run <job_id> with <literal>.summary, notypeRun <job_id> with <literal>.All four are right, so
summaryand the omitted-typedefault are covered too, not justcontent type="text".Two cases still strip the text, and I do not think either is a bug — flagging them only so nobody reopens this on the strength of them:
content type="html"→Run with <literal>.<description>→Run with <literal>.In both, the payload is HTML by definition (RFC 4287 §4.1.3.3 for the first;
descriptioncarries escaped HTML by convention for the second), so<job_id>decodes to a real<job_id>element and removing it is the correct reading. Treating those as plain text would be the opposite defect — a genuine tag surviving into the Markdown.Environment: source checkout at
4459ed0, Python 3.11.9 on Windows,beautifulsoup44.15.0,markdownify1.2.3,defusedxml0.7.1.Looks safe to close.
afourney commentedon Sep 11, 2026
Ok, I believe the core issue has been resolved. This leaves open the question of how to handle type=text that contains Markdown syntax. We could escape it, we could leave it as is, or we could fence it in a plaintext code block. Remaining behavior needs a deliberate policy decision. I'm closing this issue. Please file a new issue based on how the current main branch works, and how it may diverge from preferred behavior.