Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: HTML API: Add function to balance tags ala force_balance_tags() #5562

Draft
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

dmsnell
Copy link
Member

@dmsnell dmsnell commented Oct 24, 2023

  • adds closing tags to open elements when they implicitly close
  • does not add closing tag when hitting unsupported content that would require reconstructing active formatting elements
<p><div><button>First<button><b here>Second
↧
<p></p><div><button>First</button><button><b here>Second</b></button></div>
<p><div>asdf</p><p>Inside</p></figcaption><button>First<button><b here>Second</span></button><p></p><div>asdf<p>Inside</p><button>First</button><button><b here>Second</button></div>

```php
$balanced = WP_HTML_Processor::balance_tags( '<p><div><button>First<button><b here>Second' );
$balanced === '<p></p><div><button>First</button><button><b here>Second</b></button></div>';
```
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.

1 participant