WP_Block_Parser::parse()publicWP 5.0.0

Parses a document and returns a list of block structures

When encountering an invalid parse will return a best-effort parse. In contrast to the specification parser this does not return an error on invalid inputs.

Method of the class: WP_Block_Parser{}

No Hooks.

Return

Array[].

Usage

$WP_Block_Parser = new WP_Block_Parser();
$WP_Block_Parser->parse( $document );
$document(string) (required)
Input document being parsed.

Changelog

Since 5.0.0 Introduced.

WP_Block_Parser::parse() code WP 6.4.3

public function parse( $document ) {
	$this->document = $document;
	$this->offset   = 0;
	$this->output   = array();
	$this->stack    = array();

	while ( $this->proceed() ) {
		continue;
	}

	return $this->output;
}