Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves HTML tag find/replace functionality by replacing a regex-based implementation with a more robust selectolax-based approach. The new implementation provides better HTML parsing while maintaining exact offset tracking for surgical HTML editing capabilities.
Key changes:
- Replaced regex-only parsing with a hybrid regex+selectolax approach for better robustness
- Added comprehensive HTML rewriting functions with support for various quote styles and edge cases
- Enhanced test coverage with 800+ lines of tests covering complex scenarios
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/html/test_html_tags.py |
New comprehensive test suite covering all HTML tag manipulation functions |
src/chopdiff/html/html_tags.py |
New implementation with selectolax integration and robust HTML rewriting capabilities |
src/chopdiff/html/html_find_tags.py |
Removed old regex-only implementation |
src/chopdiff/html/__init__.py |
Updated imports to use new html_tags module |
pyproject.toml |
Added selectolax dependency |
Comments suppressed due to low confidence (1)
pyproject.toml:48
- The version 0.3.32 of selectolax does not exist. The latest available version as of January 2025 was 0.3.21. Consider using "selectolax>=0.3.21" instead.
"selectolax>=0.3.32",
|
|
||
| Does robust parsing and surgical replacement, preserving the original HTML exactly | ||
| except for the replaced attribute values. | ||
|
|
There was a problem hiding this comment.
The docstring should mention that the function ignores tags inside HTML comments, as this is an important behavior documented in the tests.
Suggested change
| Ignores tags that appear inside HTML comments; tags within comments are not rewritten. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
No description provided.