Skip to content

Fix wrapping of protected links at hyphens - #451

Open
sjh9714 wants to merge 1 commit into
Alir3z4:masterfrom
sjh9714:codex/20260930-425-protected-links
Open

sjh9714 wants to merge 1 commit into
Alir3z4:masterfrom
sjh9714:codex/20260930-425-protected-links

Conversation

@sjh9714

@sjh9714 sjh9714 commented Sep 30, 2026

Copy link
Copy Markdown

Summary

Fixes #425.

protect_links=True adds angle brackets to URLs, but the paragraph wrapper still splits them at hyphens. Disable hyphen splitting in this mode so long URLs remain intact while surrounding text wraps at whitespace. This also keeps ordinary hyphenated words together when protection is enabled; default wrapping is unchanged.

Changes

  • Correct the existing protection fixture, which expected a split URL, and cover surrounding text and automatic links through both the API and CLI.
  • Check default versus protected hyphen wrapping and update the usage notes, changelog, and authors list.

Testing

Python 3.13.13, using a virtualenv at /tmp/html2text-20260930-venv:

  • /tmp/html2text-20260930-venv/bin/python -m pytest --cov=./ --cov-report=xml:/tmp/html2text-20260930-coverage.xml -q — 198 passed.
  • /tmp/html2text-20260930-venv/bin/black --check --diff html2text/__init__.py test/test_html2text.py
  • /tmp/html2text-20260930-venv/bin/flake8
  • /tmp/html2text-20260930-venv/bin/isort --check-only --diff .
  • uvx --from mypy==1.19.1 mypy --strict html2text
  • /tmp/html2text-20260930-venv/bin/python -m build --outdir /tmp/html2text-20260930-dist

The full /tmp/html2text-20260930-venv/bin/black --check --diff . check flags an existing expression in untouched html2text/config.py with Black 26.5.1; the pristine base has the same failure. Existing pytest parametrization deprecation warnings remain. Other Python versions and operating systems were not tested locally.

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.

Line breaks in links even when setting protect_links = true

1 participant