HTML API: Replace internal logic of force_balance_tags()
#7409
+8
−1
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.
Resolved
Trac ticket: Core-55027 (February 2022)
Trac ticket: Core-44571 (July 2018)
Trac ticket: Core-40958 (June 2017)
Trac ticket: Core-39847 (February 2017)
Related
Trac ticket: Core-47514 (June 2019)
The concept of
force_balance_tags()
is tricky at best. It's purpose, however is clear: clean up HTML input no matter how "bad" it appears.The HTML API introduces a new tool based on a systematic approach to normalizing by serializing.
WP_HTML_Processor::normalize()
produces clear and consistent output HTML regardless of the input and without any special-casing for "edge cases." As a spec-compliant parser, everything is a basic case of applying the parsing rules.Since there are still documents that the HTML API cannot parse, this is an optimistic refactor. For the cases of unsupported HTML, the behavior falls back to the legacy code. When the HTML API finished supporting all content it may be possible to eliminate the legacy code, but until then, most inputs will be handled by the HTML API.