Skip to content

Fix whitespace around comments between block elements - #282

Open
ryanchou1994 wants to merge 1 commit into
matthewwithanm:developfrom
ryanchou1994:fix/comment-whitespace
Open

Fix whitespace around comments between block elements#282
ryanchou1994 wants to merge 1 commit into
matthewwithanm:developfrom
ryanchou1994:fix/comment-whitespace

Conversation

@ryanchou1994

Copy link
Copy Markdown

Summary

HTML comments between block elements can keep whitespace nodes from recognizing the neighboring blocks. For example, two paragraphs separated by four comments produce six newlines instead of two.

Resolve the neighboring content nodes while collecting children for conversion, skipping comments, doctypes, and whitespace for boundary checks. The traversal advances through siblings once and preserves the input BeautifulSoup tree.

Fixes #193.

Validation

  • Regression tests fail on the base revision and pass with this change.
  • Full test suite: 98 passed on macOS (Python 3.12.13).
  • Flake8, README lint, both mypy checks, and wheel/sdist build passed.
  • Linux (Python 3.8.20): tox -e py38 passed, including 98 tests, Flake8 and README lint; both mypy checks and wheel/sdist build passed.
  • Installed-wheel API and CLI smoke tests passed for both newline and space-separated comment runs.
  • Tests cover comment runs, inline spacing, preformatted content, and repeated conversion without changing the input tree.

Copilot AI lite review requested due to automatic review settings September 9, 2026 05:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Whitespace between comments is no longer removed

2 participants