Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu...
File: class-wp-block-processor.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Efficiently scan through block structure in document without parsing
[2] Fix | Delete
* the entire block tree and all of its JSON attributes into memory.
[3] Fix | Delete
*
[4] Fix | Delete
* @package WordPress
[5] Fix | Delete
* @subpackage Blocks
[6] Fix | Delete
* @since 6.9.0
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Class for efficiently scanning through block structure in a document
[11] Fix | Delete
* without parsing the entire block tree and JSON attributes into memory.
[12] Fix | Delete
*
[13] Fix | Delete
* ## Overview
[14] Fix | Delete
*
[15] Fix | Delete
* This class is designed to help analyze and modify block structure in a
[16] Fix | Delete
* streaming fashion and to bridge the gap between parsed block trees and
[17] Fix | Delete
* the text representing them.
[18] Fix | Delete
*
[19] Fix | Delete
* Use-cases for this class include but are not limited to:
[20] Fix | Delete
*
[21] Fix | Delete
* - Counting block types in a document.
[22] Fix | Delete
* - Queuing stylesheets based on the presence of various block types.
[23] Fix | Delete
* - Modifying blocks of a given type, i.e. migrations, updates, and styling.
[24] Fix | Delete
* - Searching for content of specific kinds, e.g. checking for blocks
[25] Fix | Delete
* with certain theme support attributes, or block bindings.
[26] Fix | Delete
* - Adding CSS class names to the element wrapping a block’s inner blocks.
[27] Fix | Delete
*
[28] Fix | Delete
* > *Note!* If a fully-parsed block tree of a document is necessary, including
[29] Fix | Delete
* > all the parsed JSON attributes, nested blocks, and HTML, consider
[30] Fix | Delete
* > using {@see \parse_blocks()} instead which will parse the document
[31] Fix | Delete
* > in one swift pass.
[32] Fix | Delete
*
[33] Fix | Delete
* For typical usage, jump first to the methods {@see self::next_block()},
[34] Fix | Delete
* {@see self::next_delimiter()}, or {@see self::next_token()}.
[35] Fix | Delete
*
[36] Fix | Delete
* ### Values
[37] Fix | Delete
*
[38] Fix | Delete
* As a lower-level interface than {@see parse_blocks()} this class follows
[39] Fix | Delete
* different performance-focused values:
[40] Fix | Delete
*
[41] Fix | Delete
* - Minimize allocations so that documents of any size may be processed
[42] Fix | Delete
* on a fixed or marginal amount of memory.
[43] Fix | Delete
* - Make hidden costs explicit so that calling code only has to pay the
[44] Fix | Delete
* performance penalty for features it needs.
[45] Fix | Delete
* - Operate with a streaming and re-entrant design to make it possible
[46] Fix | Delete
* to operate on chunks of a document and to resume after pausing.
[47] Fix | Delete
*
[48] Fix | Delete
* This means that some operations might appear more cumbersome than one
[49] Fix | Delete
* might expect. This design tradeoff opens up opportunity to wrap this in
[50] Fix | Delete
* a convenience class to add higher-level functionality.
[51] Fix | Delete
*
[52] Fix | Delete
* ## Concepts
[53] Fix | Delete
*
[54] Fix | Delete
* All text documents can be considered a block document containing a combination
[55] Fix | Delete
* of “freeform HTML” and explicit block structure. Block structure forms through
[56] Fix | Delete
* special HTML comments called _delimiters_ which include a block type and,
[57] Fix | Delete
* optionally, block attributes encoded as a JSON object payload.
[58] Fix | Delete
*
[59] Fix | Delete
* This processor is designed to scan through a block document from delimiter to
[60] Fix | Delete
* delimiter, tracking how the delimiters impact the structure of the document.
[61] Fix | Delete
* Spans of HTML appear between delimiters. If these spans exist at the top level
[62] Fix | Delete
* of the document, meaning there is no containing block around them, they are
[63] Fix | Delete
* considered freeform HTML content. If, however, they appear _inside_ block
[64] Fix | Delete
* structure they are interpreted as `innerHTML` for the containing block.
[65] Fix | Delete
*
[66] Fix | Delete
* ### Tokens and scanning
[67] Fix | Delete
*
[68] Fix | Delete
* As the processor scans through a document is reports information about the token
[69] Fix | Delete
* on which is pauses. Tokens represent spans of text in the input comprising block
[70] Fix | Delete
* delimiters and spans of HTML.
[71] Fix | Delete
*
[72] Fix | Delete
* - {@see self::next_token()} visits every contiguous subspan of text in the
[73] Fix | Delete
* input document. This includes all explicit block comment delimiters and spans
[74] Fix | Delete
* of HTML content (whether freeform or inner HTML).
[75] Fix | Delete
* - {@see self::next_delimiter()} visits every explicit block comment delimiter
[76] Fix | Delete
* unless passed a block type which covers freeform HTML content. In these cases
[77] Fix | Delete
* it will stop at top-level spans of HTML and report a `null` block type.
[78] Fix | Delete
* - {@see self::next_block()} visits every block delimiter which _opens_ a block.
[79] Fix | Delete
* This includes opening block delimiters as well as void block delimiters. With
[80] Fix | Delete
* the same exception as above for freeform HTML block types, this will visit
[81] Fix | Delete
* top-level spans of HTML content.
[82] Fix | Delete
*
[83] Fix | Delete
* When matched on a particular token, the following methods provide structural
[84] Fix | Delete
* and textual information about it:
[85] Fix | Delete
*
[86] Fix | Delete
* - {@see self::get_delimiter_type()} reports whether the delimiter is an opener,
[87] Fix | Delete
* a closer, or if it represents a whole void block.
[88] Fix | Delete
* - {@see self::get_block_type()} reports the fully-qualified block type which
[89] Fix | Delete
* the delimiter represents.
[90] Fix | Delete
* - {@see self::get_printable_block_type()} reports the fully-qualified block type,
[91] Fix | Delete
* but returns `core/freeform` instead of `null` for top-level freeform HTML content.
[92] Fix | Delete
* - {@see self::is_block_type()} indicates if the delimiter represents a block of
[93] Fix | Delete
* the given block type, or wildcard or pseudo-block type described below.
[94] Fix | Delete
* - {@see self::opens_block()} indicates if the delimiter opens a block of one
[95] Fix | Delete
* of the provided block types. Opening, void, and top-level freeform HTML content
[96] Fix | Delete
* all open blocks.
[97] Fix | Delete
* - {@see static::get_attributes()} is currently reserved for a future streaming
[98] Fix | Delete
* JSON parser class.
[99] Fix | Delete
* - {@see self::allocate_and_return_parsed_attributes()} extracts the JSON attributes
[100] Fix | Delete
* for delimiters which open blocks and return the fully-parsed attributes as an
[101] Fix | Delete
* associative array. {@see static::get_last_json_error()} for when this fails.
[102] Fix | Delete
* - {@see self::is_html()} indicates if the token is a span of HTML which might
[103] Fix | Delete
* be top-level freeform content or a block’s inner HTML.
[104] Fix | Delete
* - {@see self::get_html_content()} returns the span of HTML.
[105] Fix | Delete
* - {@see self::get_span()} for the byte offset and length into the input document
[106] Fix | Delete
* representing the token.
[107] Fix | Delete
*
[108] Fix | Delete
* It’s possible for the processor to fail to scan forward if the input document ends
[109] Fix | Delete
* in a proper prefix of an explicit block comment delimiter. For example, if the input
[110] Fix | Delete
* ends in `<!-- wp:` then it _might_ be the start of another delimiter. The parser
[111] Fix | Delete
* cannot know, however, and therefore refuses to proceed. {@see static::get_last_error()}
[112] Fix | Delete
* to distinguish between a failure to find the next token and an incomplete input.
[113] Fix | Delete
*
[114] Fix | Delete
* ### Block types
[115] Fix | Delete
*
[116] Fix | Delete
* A block’s “type” comprises an optional _namespace_ and _name_. If the namespace
[117] Fix | Delete
* isn’t provided it will be interpreted as the implicit `core` namespace. For example,
[118] Fix | Delete
* the type `gallery` is the name of the block in the `core` namespace, but the type
[119] Fix | Delete
* `abc/gallery` is the _fully-qualified_ block type for the block whose name is still
[120] Fix | Delete
* `gallery`, but in the `abc` namespace.
[121] Fix | Delete
*
[122] Fix | Delete
* Methods on this class are aware of this block naming semantic and anywhere a block
[123] Fix | Delete
* type is an argument to a method it will be normalized to account for implicit namespaces.
[124] Fix | Delete
* Passing `paragraph` is the same as passing `core/paragraph`. On the contrary, anywhere
[125] Fix | Delete
* this class returns a block type, it will return the fully-qualified and normalized form.
[126] Fix | Delete
* For example, for the `<!-- wp:group -->` delimiter it will return `core/group` as the
[127] Fix | Delete
* block type.
[128] Fix | Delete
*
[129] Fix | Delete
* There are two special block types that change the behavior of the processor:
[130] Fix | Delete
*
[131] Fix | Delete
* - The wildcard `*` represents _any block_. In addition to matching all block types,
[132] Fix | Delete
* it also represents top-level freeform HTML whose block type is reported as `null`.
[133] Fix | Delete
*
[134] Fix | Delete
* - The `core/freeform` block type is a pseudo-block type which explicitly matches
[135] Fix | Delete
* top-level freeform HTML.
[136] Fix | Delete
*
[137] Fix | Delete
* These special block types can be passed into any method which searches for blocks.
[138] Fix | Delete
*
[139] Fix | Delete
* There is one additional special block type which may be returned from
[140] Fix | Delete
* {@see self::get_printable_block_type()}. This is the `#innerHTML` type, which
[141] Fix | Delete
* indicates that the HTML span on which the processor is paused is inner HTML for
[142] Fix | Delete
* a containing block.
[143] Fix | Delete
*
[144] Fix | Delete
* ### Spans of HTML
[145] Fix | Delete
*
[146] Fix | Delete
* Non-block content plays a complicated role in processing block documents. This
[147] Fix | Delete
* processor exposes tools to help work with these spans of HTML.
[148] Fix | Delete
*
[149] Fix | Delete
* - {@see self::is_html()} indicates if the processor is paused at a span of
[150] Fix | Delete
* HTML but does not differentiate between top-level freeform content and inner HTML.
[151] Fix | Delete
* - {@see self::is_non_whitespace_html()} indicates not only if the processor
[152] Fix | Delete
* is paused at a span of HTML, but also whether that span incorporates more than
[153] Fix | Delete
* whitespace characters. Because block serialization often inserts newlines between
[154] Fix | Delete
* block comment delimiters, this is useful for distinguishing “real” freeform
[155] Fix | Delete
* content from purely aesthetic syntax.
[156] Fix | Delete
* - {@see self::is_block_type()} matches top-level freeform HTML content when
[157] Fix | Delete
* provided one of the special block types described above.
[158] Fix | Delete
*
[159] Fix | Delete
* ### Block structure
[160] Fix | Delete
*
[161] Fix | Delete
* As the processor traverses block delimiters it maintains a stack of which blocks are
[162] Fix | Delete
* open at the given place in the document where it’s paused. This stack represents the
[163] Fix | Delete
* block structure of a document and is used to determine where blocks end, which blocks
[164] Fix | Delete
* represent inner blocks, whether a span of HTML is top-level freeform content, and
[165] Fix | Delete
* more. Investigate the stack with {@see self::get_breadcrumbs()}, which returns an
[166] Fix | Delete
* array of block types starting at the outermost-open block and descending to the
[167] Fix | Delete
* currently-visited block.
[168] Fix | Delete
*
[169] Fix | Delete
* Unlike {@parse_blocks()}, spans of HTML appear in this structure as the special
[170] Fix | Delete
* reported block type `#html`. Such a span represents inner HTML for a block if the
[171] Fix | Delete
* depth reported by {@see self::get_depth()} is greater than one.
[172] Fix | Delete
*
[173] Fix | Delete
* It will generally not be necessary to inspect the stack of open blocks, though
[174] Fix | Delete
* depth may be important for finding where blocks end. When visiting a block opener,
[175] Fix | Delete
* the depth will have been increased before pausing; in contrast the depth is
[176] Fix | Delete
* decremented before visiting a closer. This makes the following an easy way to
[177] Fix | Delete
* determine if a block is still open.
[178] Fix | Delete
*
[179] Fix | Delete
* Example:
[180] Fix | Delete
*
[181] Fix | Delete
* $depth = $processor->get_depth();
[182] Fix | Delete
* while ( $processor->next_token() && $processor->get_depth() > $depth ) {
[183] Fix | Delete
* continue
[184] Fix | Delete
* }
[185] Fix | Delete
* // Processor is now paused at the token immediately following the closed block.
[186] Fix | Delete
*
[187] Fix | Delete
* #### Extracting blocks
[188] Fix | Delete
*
[189] Fix | Delete
* A unique feature of this processor is the ability to return the same output as
[190] Fix | Delete
* {@see \parse_blocks()} would produce, but for a subset of the input document.
[191] Fix | Delete
* For example, it’s possible to extract an image block, manipulate that parsed
[192] Fix | Delete
* block, and re-serialize it into the original document. It’s possible to do so
[193] Fix | Delete
* while skipping over the parse of the rest of the document.
[194] Fix | Delete
*
[195] Fix | Delete
* {@see self::extract_full_block_and_advance()} will scan forward from the current block opener
[196] Fix | Delete
* and build the parsed block structure until the current block is closed. It will
[197] Fix | Delete
* include all inner HTML and inner blocks, and parse all of the inner blocks. It
[198] Fix | Delete
* can be used to extract a block at any depth in the document, helpful for operating
[199] Fix | Delete
* on blocks within nested structure.
[200] Fix | Delete
*
[201] Fix | Delete
* Example:
[202] Fix | Delete
*
[203] Fix | Delete
* if ( ! $processor->next_block( 'gallery' ) ) {
[204] Fix | Delete
* return $post_content;
[205] Fix | Delete
* }
[206] Fix | Delete
*
[207] Fix | Delete
* $gallery_at = $processor->get_span()->start;
[208] Fix | Delete
* $gallery_block = $processor->extract_full_block_and_advance();
[209] Fix | Delete
* $after_gallery = $processor->get_span()->start;
[210] Fix | Delete
* return (
[211] Fix | Delete
* substr( $post_content, 0, $gallery_at ) .
[212] Fix | Delete
* serialize_block( modify_gallery( $gallery_block ) .
[213] Fix | Delete
* substr( $post_content, $after_gallery )
[214] Fix | Delete
* );
[215] Fix | Delete
*
[216] Fix | Delete
* #### Handling of malformed structure
[217] Fix | Delete
*
[218] Fix | Delete
* There are situations where closing block delimiters appear for which no open block
[219] Fix | Delete
* exists, or where a document ends before a block is closed, or where a closing block
[220] Fix | Delete
* delimiter appears but references a different block type than the most-recently
[221] Fix | Delete
* opened block does. In all of these cases, the stack of open blocks should mirror
[222] Fix | Delete
* the behavior in {@see \parse_blocks()}.
[223] Fix | Delete
*
[224] Fix | Delete
* Unlike {@see \parse_blocks()}, however, this processor can still operate on the
[225] Fix | Delete
* invalid block delimiters. It provides a few functions which can be used for building
[226] Fix | Delete
* custom and non-spec-compliant error handling.
[227] Fix | Delete
*
[228] Fix | Delete
* - {@see self::has_closing_flag()} indicates if the block delimiter contains the
[229] Fix | Delete
* closing flag at the end. Some invalid block delimiters might contain both the
[230] Fix | Delete
* void and closing flag, in which case {@see self::get_delimiter_type()} will
[231] Fix | Delete
* report that it’s a void block.
[232] Fix | Delete
* - {@see static::get_last_error()} indicates if the processor reached an invalid
[233] Fix | Delete
* block closing. Depending on the context, {@see \parse_blocks()} might instead
[234] Fix | Delete
* ignore the token or treat it as freeform HTML content.
[235] Fix | Delete
*
[236] Fix | Delete
* ## Static helpers
[237] Fix | Delete
*
[238] Fix | Delete
* This class provides helpers for performing semantic block-related operations.
[239] Fix | Delete
*
[240] Fix | Delete
* - {@see self::normalize_block_type()} takes a block type with or without the
[241] Fix | Delete
* implicit `core` namespace and returns a fully-qualified block type.
[242] Fix | Delete
* - {@see self::are_equal_block_types()} indicates if two spans across one or
[243] Fix | Delete
* more input texts represent the same fully-qualified block type.
[244] Fix | Delete
*
[245] Fix | Delete
* ## Subclassing
[246] Fix | Delete
*
[247] Fix | Delete
* This processor is designed to accurately parse a block document. Therefore, many
[248] Fix | Delete
* of its methods are not meant for subclassing. However, overall this class supports
[249] Fix | Delete
* building higher-level convenience classes which may choose to subclass it. For those
[250] Fix | Delete
* classes, avoid re-implementing methods except for the list below. Instead, create
[251] Fix | Delete
* new names representing the higher-level concepts being introduced. For example, instead
[252] Fix | Delete
* of creating a new method named `next_block()` which only advances to blocks of a given
[253] Fix | Delete
* kind, consider creating a new method named something like `next_layout_block()` which
[254] Fix | Delete
* won’t interfere with the base class method.
[255] Fix | Delete
*
[256] Fix | Delete
* - {@see static::get_last_error()} may be reimplemented to report new errors in the subclass
[257] Fix | Delete
* which aren’t intrinsic to block parsing.
[258] Fix | Delete
* - {@see static::get_attributes()} may be reimplemented to provide a streaming interface
[259] Fix | Delete
* to reading and modifying a block’s JSON attributes. It should be fast and memory efficient.
[260] Fix | Delete
* - {@see static::get_last_json_error()} may be reimplemented to report new errors introduced
[261] Fix | Delete
* with a reimplementation of {@see static::get_attributes()}.
[262] Fix | Delete
*
[263] Fix | Delete
* @since 6.9.0
[264] Fix | Delete
*/
[265] Fix | Delete
class WP_Block_Processor {
[266] Fix | Delete
/**
[267] Fix | Delete
* Indicates if the last operation failed, otherwise
[268] Fix | Delete
* will be `null` for success.
[269] Fix | Delete
*
[270] Fix | Delete
* @since 6.9.0
[271] Fix | Delete
*
[272] Fix | Delete
* @var string|null
[273] Fix | Delete
*/
[274] Fix | Delete
private $last_error = null;
[275] Fix | Delete
[276] Fix | Delete
/**
[277] Fix | Delete
* Indicates failures from decoding JSON attributes.
[278] Fix | Delete
*
[279] Fix | Delete
* @since 6.9.0
[280] Fix | Delete
*
[281] Fix | Delete
* @see \json_last_error()
[282] Fix | Delete
*
[283] Fix | Delete
* @var int
[284] Fix | Delete
*/
[285] Fix | Delete
private $last_json_error = JSON_ERROR_NONE;
[286] Fix | Delete
[287] Fix | Delete
/**
[288] Fix | Delete
* Source text provided to processor.
[289] Fix | Delete
*
[290] Fix | Delete
* @since 6.9.0
[291] Fix | Delete
*
[292] Fix | Delete
* @var string
[293] Fix | Delete
*/
[294] Fix | Delete
protected $source_text;
[295] Fix | Delete
[296] Fix | Delete
/**
[297] Fix | Delete
* Byte offset into source text where a matched delimiter starts.
[298] Fix | Delete
*
[299] Fix | Delete
* Example:
[300] Fix | Delete
*
[301] Fix | Delete
* 5 10 15 20 25 30 35 40 45 50
[302] Fix | Delete
* <!-- wp:group --><!-- wp:void /--><!-- /wp:group -->
[303] Fix | Delete
* ╰─ Starts at byte offset 17.
[304] Fix | Delete
*
[305] Fix | Delete
* @since 6.9.0
[306] Fix | Delete
*
[307] Fix | Delete
* @var int
[308] Fix | Delete
*/
[309] Fix | Delete
private $matched_delimiter_at = 0;
[310] Fix | Delete
[311] Fix | Delete
/**
[312] Fix | Delete
* Byte length of full span of a matched delimiter.
[313] Fix | Delete
*
[314] Fix | Delete
* Example:
[315] Fix | Delete
*
[316] Fix | Delete
* 5 10 15 20 25 30 35 40 45 50
[317] Fix | Delete
* <!-- wp:group --><!-- wp:void /--><!-- /wp:group -->
[318] Fix | Delete
* ╰───────────────╯
[319] Fix | Delete
* 17 bytes long.
[320] Fix | Delete
*
[321] Fix | Delete
* @since 6.9.0
[322] Fix | Delete
*
[323] Fix | Delete
* @var int
[324] Fix | Delete
*/
[325] Fix | Delete
private $matched_delimiter_length = 0;
[326] Fix | Delete
[327] Fix | Delete
/**
[328] Fix | Delete
* First byte offset into source text following any previously-matched delimiter.
[329] Fix | Delete
* Used to indicate where an HTML span starts.
[330] Fix | Delete
*
[331] Fix | Delete
* Example:
[332] Fix | Delete
*
[333] Fix | Delete
* 5 10 15 20 25 30 35 40 45 50 55
[334] Fix | Delete
* <!-- wp:paragraph --><p>Content</p><⃨!⃨-⃨-⃨ ⃨/⃨w⃨p⃨:⃨p⃨a⃨r⃨a⃨g⃨r⃨a⃨p⃨h⃨ ⃨-⃨-⃨>⃨
[335] Fix | Delete
* │ ╰─ This delimiter was matched, and after matching,
[336] Fix | Delete
* │ revealed the preceding HTML span.
[337] Fix | Delete
* │
[338] Fix | Delete
* ╰─ The first byte offset after the previous matched delimiter
[339] Fix | Delete
* is 21. Because the matched delimiter starts at 55, which is after
[340] Fix | Delete
* this, a span of HTML must exist between these boundaries.
[341] Fix | Delete
*
[342] Fix | Delete
* @since 6.9.0
[343] Fix | Delete
*
[344] Fix | Delete
* @var int
[345] Fix | Delete
*/
[346] Fix | Delete
private $after_previous_delimiter = 0;
[347] Fix | Delete
[348] Fix | Delete
/**
[349] Fix | Delete
* Byte offset where namespace span begins.
[350] Fix | Delete
*
[351] Fix | Delete
* When no namespace is present, this will be the same as the starting
[352] Fix | Delete
* byte offset for the block name.
[353] Fix | Delete
*
[354] Fix | Delete
* Example:
[355] Fix | Delete
*
[356] Fix | Delete
* <!-- wp:core/gallery -->
[357] Fix | Delete
* │ ╰─ Name starts here.
[358] Fix | Delete
* ╰─ Namespace starts here.
[359] Fix | Delete
*
[360] Fix | Delete
* <!-- wp:gallery -->
[361] Fix | Delete
* ├─ The namespace would start here but is implied as “core.”
[362] Fix | Delete
* ╰─ The name starts here.
[363] Fix | Delete
*
[364] Fix | Delete
* @since 6.9.0
[365] Fix | Delete
*
[366] Fix | Delete
* @var int
[367] Fix | Delete
*/
[368] Fix | Delete
private $namespace_at = 0;
[369] Fix | Delete
[370] Fix | Delete
/**
[371] Fix | Delete
* Byte offset where block name span begins.
[372] Fix | Delete
*
[373] Fix | Delete
* When no namespace is present, this will be the same as the starting
[374] Fix | Delete
* byte offset for the block namespace.
[375] Fix | Delete
*
[376] Fix | Delete
* Example:
[377] Fix | Delete
*
[378] Fix | Delete
* <!-- wp:core/gallery -->
[379] Fix | Delete
* │ ╰─ Name starts here.
[380] Fix | Delete
* ╰─ Namespace starts here.
[381] Fix | Delete
*
[382] Fix | Delete
* <!-- wp:gallery -->
[383] Fix | Delete
* ├─ The namespace would start here but is implied as “core.”
[384] Fix | Delete
* ╰─ The name starts here.
[385] Fix | Delete
*
[386] Fix | Delete
* @since 6.9.0
[387] Fix | Delete
*
[388] Fix | Delete
* @var int
[389] Fix | Delete
*/
[390] Fix | Delete
private $name_at = 0;
[391] Fix | Delete
[392] Fix | Delete
/**
[393] Fix | Delete
* Byte length of block name span.
[394] Fix | Delete
*
[395] Fix | Delete
* Example:
[396] Fix | Delete
*
[397] Fix | Delete
* 5 10 15 20 25
[398] Fix | Delete
* <!-- wp:core/gallery -->
[399] Fix | Delete
* ╰─────╯
[400] Fix | Delete
* 7 bytes long.
[401] Fix | Delete
*
[402] Fix | Delete
* @since 6.9.0
[403] Fix | Delete
*
[404] Fix | Delete
* @var int
[405] Fix | Delete
*/
[406] Fix | Delete
private $name_length = 0;
[407] Fix | Delete
[408] Fix | Delete
/**
[409] Fix | Delete
* Whether the delimiter contains the block-closing flag.
[410] Fix | Delete
*
[411] Fix | Delete
* This may be erroneous if present within a void block,
[412] Fix | Delete
* therefore the {@see self::has_closing_flag()} can be used by
[413] Fix | Delete
* calling code to perform custom error-handling.
[414] Fix | Delete
*
[415] Fix | Delete
* @since 6.9.0
[416] Fix | Delete
*
[417] Fix | Delete
* @var bool
[418] Fix | Delete
*/
[419] Fix | Delete
private $has_closing_flag = false;
[420] Fix | Delete
[421] Fix | Delete
/**
[422] Fix | Delete
* Byte offset where JSON attributes span begins.
[423] Fix | Delete
*
[424] Fix | Delete
* Example:
[425] Fix | Delete
*
[426] Fix | Delete
* 5 10 15 20 25 30 35 40
[427] Fix | Delete
* <!-- wp:paragraph {"dropCaps":true} -->
[428] Fix | Delete
* ╰─ Starts at byte offset 18.
[429] Fix | Delete
*
[430] Fix | Delete
* @since 6.9.0
[431] Fix | Delete
*
[432] Fix | Delete
* @var int
[433] Fix | Delete
*/
[434] Fix | Delete
private $json_at;
[435] Fix | Delete
[436] Fix | Delete
/**
[437] Fix | Delete
* Byte length of JSON attributes span, or 0 if none are present.
[438] Fix | Delete
*
[439] Fix | Delete
* Example:
[440] Fix | Delete
*
[441] Fix | Delete
* 5 10 15 20 25 30 35 40
[442] Fix | Delete
* <!-- wp:paragraph {"dropCaps":true} -->
[443] Fix | Delete
* ╰───────────────╯
[444] Fix | Delete
* 17 bytes long.
[445] Fix | Delete
*
[446] Fix | Delete
* @since 6.9.0
[447] Fix | Delete
*
[448] Fix | Delete
* @var int
[449] Fix | Delete
*/
[450] Fix | Delete
private $json_length = 0;
[451] Fix | Delete
[452] Fix | Delete
/**
[453] Fix | Delete
* Internal parser state, differentiating whether the instance is currently matched,
[454] Fix | Delete
* on an implicit freeform node, in error, or ready to begin parsing.
[455] Fix | Delete
*
[456] Fix | Delete
* @see self::READY
[457] Fix | Delete
* @see self::MATCHED
[458] Fix | Delete
* @see self::HTML_SPAN
[459] Fix | Delete
* @see self::INCOMPLETE_INPUT
[460] Fix | Delete
* @see self::COMPLETE
[461] Fix | Delete
*
[462] Fix | Delete
* @since 6.9.0
[463] Fix | Delete
*
[464] Fix | Delete
* @var string
[465] Fix | Delete
*/
[466] Fix | Delete
protected $state = self::READY;
[467] Fix | Delete
[468] Fix | Delete
/**
[469] Fix | Delete
* Indicates what kind of block comment delimiter was matched.
[470] Fix | Delete
*
[471] Fix | Delete
* One of:
[472] Fix | Delete
*
[473] Fix | Delete
* - {@see self::OPENER} If the delimiter is opening a block.
[474] Fix | Delete
* - {@see self::CLOSER} If the delimiter is closing an open block.
[475] Fix | Delete
* - {@see self::VOID} If the delimiter represents a void block with no inner content.
[476] Fix | Delete
*
[477] Fix | Delete
* If a parsed comment delimiter contains both the closing and the void
[478] Fix | Delete
* flags then it will be interpreted as a void block to match the behavior
[479] Fix | Delete
* of the official block parser, however, this is a syntax error and probably
[480] Fix | Delete
* the block ought to close an open block of the same name, if one is open.
[481] Fix | Delete
*
[482] Fix | Delete
* @since 6.9.0
[483] Fix | Delete
*
[484] Fix | Delete
* @var string
[485] Fix | Delete
*/
[486] Fix | Delete
private $type;
[487] Fix | Delete
[488] Fix | Delete
/**
[489] Fix | Delete
* Whether the last-matched delimiter acts like a void block and should be
[490] Fix | Delete
* popped from the stack of open blocks as soon as the parser advances.
[491] Fix | Delete
*
[492] Fix | Delete
* This applies to void block delimiters and to HTML spans.
[493] Fix | Delete
*
[494] Fix | Delete
* @since 6.9.0
[495] Fix | Delete
*
[496] Fix | Delete
* @var bool
[497] Fix | Delete
*/
[498] Fix | Delete
private $was_void = false;
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function