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

Add WP_HTML_Processor #47573

Closed
wants to merge 18 commits into from
Closed

Add WP_HTML_Processor #47573

wants to merge 18 commits into from

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Jan 30, 2023

What?

Part of #44410.

Add WP_HTML_Processor, a subclass of WP_Tag_HTML_Processor, which allows "broader" access to the parsed HTML, by providing the get_content_inside_balanced_tags() method, and some related helper methods, such as balanced_next().

Why?

This is a requirement for the Block Interactivity API (see WordPress/block-interactivity-experiments#120). Furthermore, balanced_next() is also a prerequisite for set_content_inside_balanced_tags() (see #47036).

How?

The code is copy-pasted from @dmsnell's #46345 (which has a much wider scope). I've only applied some formatting, fixed some lint errors, and added some PHPDoc.

Testing Instructions

See unit tests!

TODO

  • Separate file for WP_HTML_Processor_Scan_State
  • PHPDoc
  • Add/update @since
  • PHPDoc for tests?

@ockham ockham added the [Type] Experimental Experimental feature or API. label Jan 30, 2023
@ockham ockham self-assigned this Jan 30, 2023
@github-actions
Copy link

github-actions bot commented Jan 30, 2023

Flaky tests detected in 35bd051.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4053307533
📝 Reported issues:

@ockham
Copy link
Contributor Author

ockham commented Jan 31, 2023

Opening for review. As stated in the PR desc, this is pretty much copy-pasted from @dmsnell's #46345.

Not sure if you'd rather make any changes to the API and/or test coverage -- I wanted to open this early to get the ball rolling for get_content_inside_balanced_tags 😊

@ockham
Copy link
Contributor Author

ockham commented Mar 6, 2023

Closing. Per recent discussions, we're going to unblock the work in the BHE repo by implementing missing features in a subclass of WP_HTML_Tag_Processor right there (e.g.).

Development of the HTML Processor API is expected to progress more cautiously/slowly, to take into account more exotic HTML constructs; it will happen in (forks of) the wordpress-develop repo (e.g.).

@ockham ockham closed this Mar 6, 2023
@ockham ockham deleted the add/html-processor branch March 6, 2023 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Experimental Experimental feature or API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants