Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The change
Finish parsing the input in
html2text()before collecting its text.HTMLParser.feed()can buffer a trailing character reference or ampersand-containing word untilclose()signals end of input. Without that call,html2text('R&D')returns'', andhtml2text('<p>Hello</p> R&D')returns'Hello', silently dropping text.Call
close()afterfeed(). The regression cases cover a plain trailing ampersand-containing word, text after an HTML element, named/decimal/hexadecimal character references without a semicolon, complete markup, and empty input. Five of these cases failed on the unchanged implementation.Validation on Linux:
uvx --with tox-uv tox -e py312: 678 passed.uvx --with tox-uv tox -e py312,py313: 685 passed in each environment (Python 3.12.14 and 3.13.5).uvx --with tox-uv tox -e py314: 685 passed, 5 deprecation warnings (Python 3.14.8).git diff --check: passed.All tox runs include the complete test suite and module doctests, using the built package. Other interpreter versions and operating systems were not run locally. Searched existing open/closed issues and PRs for
html2text,HTMLTextExtractor, andampersand, and checked open PR titles; found no overlapping fix.The HTMLParser documentation describes the end-of-input processing that this wrapper was missing.
AI assistance
Prepared and tested with OpenAI Codex assistance.