@wordpress/block-serialization-default-parser 4.18.1-next.4d3b314fd5.0 → 4.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +2 -2
  3. package/parser.php +12 -12
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.20.0 (2022-10-19)
6
+
7
+ ## 4.19.0 (2022-10-05)
8
+
5
9
  ## 4.18.0 (2022-09-21)
6
10
 
7
11
  ## 4.17.0 (2022-09-13)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-serialization-default-parser",
3
- "version": "4.18.1-next.4d3b314fd5.0",
3
+ "version": "4.20.0",
4
4
  "description": "Block serialization specification parser for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "25054766423cb49d959eb656c2533530073ff5c2"
36
+ "gitHead": "a2ff0e6471c88436dad0287beb88d1729aa6f5dd"
37
37
  }
package/parser.php CHANGED
@@ -80,7 +80,7 @@ class WP_Block_Parser_Block {
80
80
  * @param string $innerHTML Resultant HTML from inside block comment delimiters after removing inner blocks.
81
81
  * @param array $innerContent List of string fragments and null markers where inner blocks were found.
82
82
  */
83
- function __construct( $name, $attrs, $innerBlocks, $innerHTML, $innerContent ) {
83
+ public function __construct( $name, $attrs, $innerBlocks, $innerHTML, $innerContent ) {
84
84
  $this->blockName = $name;
85
85
  $this->attrs = $attrs;
86
86
  $this->innerBlocks = $innerBlocks;
@@ -152,7 +152,7 @@ class WP_Block_Parser_Frame {
152
152
  * @param int $prev_offset Byte offset into document for after parse token ends.
153
153
  * @param int $leading_html_start Byte offset into document where leading HTML before token starts.
154
154
  */
155
- function __construct( $block, $token_start, $token_length, $prev_offset = null, $leading_html_start = null ) {
155
+ public function __construct( $block, $token_start, $token_length, $prev_offset = null, $leading_html_start = null ) {
156
156
  $this->block = $block;
157
157
  $this->token_start = $token_start;
158
158
  $this->token_length = $token_length;
@@ -224,16 +224,16 @@ class WP_Block_Parser {
224
224
  * @param string $document Input document being parsed.
225
225
  * @return array[]
226
226
  */
227
- function parse( $document ) {
227
+ public function parse( $document ) {
228
228
  $this->document = $document;
229
229
  $this->offset = 0;
230
230
  $this->output = array();
231
231
  $this->stack = array();
232
232
  $this->empty_attrs = json_decode( '{}', true );
233
233
 
234
- do {
235
- // twiddle our thumbs.
236
- } while ( $this->proceed() );
234
+ while ( $this->proceed() ) {
235
+ continue;
236
+ }
237
237
 
238
238
  return $this->output;
239
239
  }
@@ -252,7 +252,7 @@ class WP_Block_Parser {
252
252
  * @since 5.0.0
253
253
  * @return bool
254
254
  */
255
- function proceed() {
255
+ public function proceed() {
256
256
  $next_token = $this->next_token();
257
257
  list( $token_type, $block_name, $attrs, $start_offset, $token_length ) = $next_token;
258
258
  $stack_depth = count( $this->stack );
@@ -398,7 +398,7 @@ class WP_Block_Parser {
398
398
  * @since 4.6.1 fixed a bug in attribute parsing which caused catastrophic backtracking on invalid block comments
399
399
  * @return array
400
400
  */
401
- function next_token() {
401
+ public function next_token() {
402
402
  $matches = null;
403
403
 
404
404
  /*
@@ -473,7 +473,7 @@ class WP_Block_Parser {
473
473
  * @param string $innerHTML HTML content of block.
474
474
  * @return WP_Block_Parser_Block freeform block object.
475
475
  */
476
- function freeform( $innerHTML ) {
476
+ public function freeform( $innerHTML ) {
477
477
  return new WP_Block_Parser_Block( null, $this->empty_attrs, array(), $innerHTML, array( $innerHTML ) );
478
478
  }
479
479
 
@@ -485,7 +485,7 @@ class WP_Block_Parser {
485
485
  * @since 5.0.0
486
486
  * @param null $length how many bytes of document text to output.
487
487
  */
488
- function add_freeform( $length = null ) {
488
+ public function add_freeform( $length = null ) {
489
489
  $length = $length ? $length : strlen( $this->document ) - $this->offset;
490
490
 
491
491
  if ( 0 === $length ) {
@@ -506,7 +506,7 @@ class WP_Block_Parser {
506
506
  * @param int $token_length Byte length of entire block from start of opening token to end of closing token.
507
507
  * @param int|null $last_offset Last byte offset into document if continuing form earlier output.
508
508
  */
509
- function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) {
509
+ public function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) {
510
510
  $parent = $this->stack[ count( $this->stack ) - 1 ];
511
511
  $parent->block->innerBlocks[] = (array) $block;
512
512
  $html = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset );
@@ -527,7 +527,7 @@ class WP_Block_Parser {
527
527
  * @since 5.0.0
528
528
  * @param int|null $end_offset byte offset into document for where we should stop sending text output as HTML.
529
529
  */
530
- function add_block_from_stack( $end_offset = null ) {
530
+ public function add_block_from_stack( $end_offset = null ) {
531
531
  $stack_top = array_pop( $this->stack );
532
532
  $prev_offset = $stack_top->prev_offset;
533
533