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: Allow extending input document for chunked processing. #5050

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

dmsnell
Copy link
Member

@dmsnell dmsnell commented Aug 22, 2023

This work is still at an early stage. It will change, possibly substantially, before it's ready for full review.

Description

In some situations it may be useful to process an HTML document as it's being generated. This requires the ability to add chunks of text to the end of the input HTML.

In this patch the WP_HTML_Tag_Processor::extend_input( $html ) method is providing this ability. It is designed to allow for splitting an HTML at arbitrary boundaries.

$p = WP_HTML_Processor::createFragment( '<div><p><em>This</em> is <str' );
while ( $p->next_tag() ) {
	// Process everything up to this point.
}

$p->extend_input( 'ong>incomplete.</strong></p><img></div>' );
while ( $p->next_tag() ) {
	// Continue processing with the full contents.
}

In some situations it may be useful to process an HTML document as it's being
generated. This requires the ability to add chunks of text to the end of the
input HTML.

In this patch the `WP_HTML_Tag_Processor::extend_input( $html )` method is
providing this ability. It is designed to allow for splitting an HTML at
arbitrary boundaries.
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