fix: prefer data-src over placeholder data URI in img src - #2417
fix: prefer data-src over placeholder data URI in img src#2417Machen John (macjayz) wants to merge 1 commit into
Conversation
Diogo Damasceno (Diogo-Damasceno)
left a comment
There was a problem hiding this comment.
Verified locally (Arch Linux, Python 3.14.7, markitdown from source at b6e8bbd).
Reproduced before the fix. Applying only this PR's test file to main without the source change fails 1 test (test_img_prefers_data_src_over_placeholder_data_uri), so the placeholder data URI does currently win over the real URL in data-src.
After the fix: all 10 tests in test_html_converter.py pass. Wider selection (-k "html or markdownify", ignoring test_outlook_msg_ansi.py which fails to collect here for an unrelated missing module): 24 passed / 2 failed with the change vs 20 passed / 2 failed on main. The 2 failures are the test_docintel_* tests, failing identically before and after, so they are pre-existing in my environment. No regressions.
Small note, not a blocker: src[:5].lower() == "data:" matches the scheme without requiring a colon-normalised parse. It is fine for real-world markup, and DATA:/Data: are covered by the .lower().
convert_img falls back to data-src only when src is missing or empty. Lazy-loaded images commonly leave a placeholder data: URI in src and the real URL in data-src, so that case still lost the real image. This treats a data: URI in src the same as empty when data-src is present.