[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-wp-block-parser.php (summary)

Block Serialization Parser

File Size: 555 lines (15 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 classes

WP_Block_Parser_Block:: (1 method):
  __construct()

WP_Block_Parser_Frame:: (1 method):
  __construct()

WP_Block_Parser:: (7 methods):
  parse()
  proceed()
  next_token()
  freeform()
  add_freeform()
  add_inner_block()
  add_block_from_stack()


Class: WP_Block_Parser_Block  - X-Ref

Class WP_Block_Parser_Block

Holds the block structure in memory

__construct( $name, $attrs, $innerBlocks, $innerHTML, $innerContent )   X-Ref
Constructor.

Will populate object properties from the provided arguments.

param: string $name         Name of block.
param: array  $attrs        Optional set of attributes from block comment delimiters.
param: array  $innerBlocks  List of inner blocks (of this same class).
param: string $innerHTML    Resultant HTML from inside block comment delimiters after removing inner blocks.
param: array  $innerContent List of string fragments and null markers where inner blocks were found.
since: 5.0.0

Class: WP_Block_Parser_Frame  - X-Ref

Class WP_Block_Parser_Frame

Holds partial blocks in memory while parsing

__construct( $block, $token_start, $token_length, $prev_offset = null, $leading_html_start = null )   X-Ref
Constructor

Will populate object properties from the provided arguments.

param: WP_Block_Parser_Block $block              Full or partial block.
param: int                   $token_start        Byte offset into document for start of parse token.
param: int                   $token_length       Byte length of entire parse token string.
param: int                   $prev_offset        Byte offset into document for after parse token ends.
param: int                   $leading_html_start Byte offset into document where leading HTML before token starts.
since: 5.0.0

Class: WP_Block_Parser  - X-Ref

Class WP_Block_Parser

Parses a document and constructs a list of parsed block objects

parse( $document )   X-Ref
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.

param: string $document Input document being parsed.
return: WP_Block_Parser_Block[]
since: 5.0.0

proceed()   X-Ref
Processes the next token from the input document
and returns whether to proceed eating more tokens

This is the "next step" function that essentially
takes a token as its input and decides what to do
with that token before descending deeper into a
nested block tree or continuing along the document
or breaking out of a level of nesting.

return: bool
since: 5.0.0

next_token()   X-Ref
Scans the document from where we last left off
and finds the next valid token to parse if it exists

Returns the type of the find: kind of find, block information, attributes

return: array
since: 5.0.0
since: 4.6.1 fixed a bug in attribute parsing which caused catastrophic backtracking on invalid block comments

freeform( $innerHTML )   X-Ref
Returns a new block object for freeform HTML

param: string $innerHTML HTML content of block.
return: WP_Block_Parser_Block freeform block object.
since: 3.9.0

add_freeform( $length = null )   X-Ref
Pushes a length of text from the input document
to the output list as a freeform block.

param: null $length how many bytes of document text to output.
since: 5.0.0

add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null )   X-Ref
Given a block structure from memory pushes
a new block to the output list.

param: WP_Block_Parser_Block $block        The block to add to the output.
param: int                   $token_start  Byte offset into the document where the first token for the block starts.
param: int                   $token_length Byte length of entire block from start of opening token to end of closing token.
param: int|null              $last_offset  Last byte offset into document if continuing form earlier output.
since: 5.0.0

add_block_from_stack( $end_offset = null )   X-Ref
Pushes the top block from the parsing stack to the output list.

param: int|null $end_offset byte offset into document for where we should stop sending text output as HTML.
since: 5.0.0



Generated: Sun Dec 22 01:00:02 2024 Cross-referenced by PHPXref 0.7.1