#2482·markitdown

HTML: <title> leaks into markdown body for documents without <body>; stray content outside <body> dropped

Author: ManoharPaturiCreated Sep 13, 2026Updated Sep 13, 2026
### Description `HtmlConverter` converts only the `` element when present, and the whole document otherwise. Since BeautifulSoup's `html.parser` does not synthesize or relocate elements the way a browser does: - a valid HTML5 document without `` tags leaks its `` text into the markdown body - any content placed before/after `<body>` is silently dropped ### Reproduction ```python from io import BytesIO from markitdown import MarkItDown, StreamInfo html = b'<html><head><title>Page Title

hello

' MarkItDown().convert_stream(BytesIO(html), stream_info=StreamInfo(extension='.html')).markdown # 'Page Title\n\nhello' <-- title leaks into the body html2 = b'before

in body

after' # 'before' and 'after' are dropped entirely ``` ### Expected behavior Head metadata stays out of the markdown (except when used as the doc title), and stray content outside `` is preserved, matching what a browser considers rendered content. ### Environment markitdown main (`cc0ca9e`), Python 3.12