Skip to content

Reset emphasis spacing context between handle calls - #453

Open
ac1982 wants to merge 1 commit into
Alir3z4:masterfrom
ac1982:fix-reused-emphasis-spacing
Open

ac1982 wants to merge 1 commit into
Alir3z4:masterfrom
ac1982:fix-reused-emphasis-spacing

Conversation

@ac1982

@ac1982 ac1982 commented Oct 11, 2026

Copy link
Copy Markdown

Reusing an HTML2Text instance can add a leading space to emphasized text in later documents. For example, calling handle("<em>hello</em>") twice produces _hello_ first and _hello_ second. Text from a previous plain document can also affect a later emphasized document.

Clear preceding_data at the start of handle, alongside the existing start reset, so spacing decisions only inspect the current document. Add repeated-call cases across all eight emphasis/strike tags and a cross-document case. Update the changelog and contributor list as requested by the contribution guide.

Related to #375. #362 resets start for repeated calls, but leaves the text used by emphasis spacing intact.

Validation on Linux/arm64:

  • Nine new cases fail before the fix.
  • Full suite: 221 passed on Python 3.9.25 and 3.13.16 (three pre-existing invalid-escape warnings on 3.13).
  • Black, Flake8, isort, and mypy --strict html2text pass.

AI assistance: this change and its tests were developed and verified with an AI coding agent.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant