[IMP] convert_html_fragment: prevent lxml wraps and false positives #349
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.
When the fragment has no common node, lxml wraps the code under a common one.
This content for instance:
is parsed as:
To avoid this we force a custom wrapper tag on every parsed string so every xml
receives the same treatment and we can extract it later with no harm.
We don't want to update any fragment which has no changes after all the
replacements are checked. For that cases we'll return the original string.
At the end, we just trim our initial custom wrapper tag and return our
treated string.
I made this test case and tested it in a v16 shell:
cc @Tecnativa TT44169 TT45734
please take a look @pedrobaeza