Skip to content

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

Draft
dmsnell wants to merge 4 commits intoWordPress:trunkfrom
dmsnell:html-api/add-balance-tags
Draft

WIP: HTML API: Add function to balance tags ala force_balance_tags()#5562
dmsnell wants to merge 4 commits intoWordPress:trunkfrom
dmsnell:html-api/add-balance-tags

Conversation

@dmsnell
Copy link
Copy Markdown
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>

@dmsnell dmsnell force-pushed the html-api/add-balance-tags branch from 98fc992 to cac3c8f Compare October 24, 2023 08:31
```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>';
```
@dmsnell dmsnell force-pushed the html-api/add-balance-tags branch from cac3c8f to c6609fa Compare October 24, 2023 08:32
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