Skip to content

Commit 4625a42

Browse files
committed
Rename get_html_content_and_advance since HTML spans are not void/atomic.
1 parent 6346cbe commit 4625a42

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/wp-includes/class-wp-block-processor.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
* associative array. {@see static::get_last_json_error()} for when this fails.
104104
* - {@see self::is_html()} indicates if the token is a span of HTML which might
105105
* be top-level freeform content or a block’s inner HTML.
106-
* - {@see self::get_html_content_and_advance()} returns the span of HTML.
106+
* - {@see self::get_html_content()} returns the span of HTML.
107107
* - {@see self::get_span()} for the byte offset and length into the input document
108108
* representing the token.
109109
*
@@ -1256,7 +1256,7 @@ public function get_depth(): int {
12561256
*/
12571257
public function extract_block(): ?array {
12581258
if ( $this->is_html() ) {
1259-
$chunk = $this->get_html_content_and_advance();
1259+
$chunk = $this->get_html_content();
12601260

12611261
return array(
12621262
'blockName' => null,
@@ -1278,7 +1278,7 @@ public function extract_block(): ?array {
12781278
$depth = $this->get_depth();
12791279
while ( $this->next_token() && $this->get_depth() > $depth ) {
12801280
if ( $this->is_html() ) {
1281-
$chunk = $this->get_html_content_and_advance();
1281+
$chunk = $this->get_html_content();
12821282
$block['innerHTML'] .= $chunk;
12831283
$block['innerContent'][] = $chunk;
12841284
continue;
@@ -1639,14 +1639,13 @@ public function is_non_whitespace_html(): bool {
16391639
}
16401640

16411641
/**
1642-
* Returns the string content of an HTML span and advances the parser so that
1643-
* the next delimiter will be after the HTML span.
1642+
* Returns the string content of a matched HTML span, or `null` otherwise.
16441643
*
16451644
* @since 6.9.0
16461645
*
1647-
* @return string|null HTML content, or `null` if not currently matched on HTML.
1646+
* @return string|null Raw HTML content, or `null` if not currently matched on HTML.
16481647
*/
1649-
public function get_html_content_and_advance(): ?string {
1648+
public function get_html_content(): ?string {
16501649
if ( ! $this->is_html() ) {
16511650
return null;
16521651
}

tests/phpunit/tests/block-processor/wpBlockProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function test_finds_open_and_inner_html_and_close_of_post_with_basic_bloc
136136

137137
$this->assertSame(
138138
'<p>Content</p>',
139-
$processor->get_html_content_and_advance(),
139+
$processor->get_html_content(),
140140
'Failed to extract the block’s inner HTML.'
141141
);
142142

@@ -264,7 +264,7 @@ public function test_rejects_invalid_block_comment_delimiters_as_html_comments(
264264

265265
$this->assertSame(
266266
$html,
267-
$processor->get_html_content_and_advance(),
267+
$processor->get_html_content(),
268268
'Failed to extract the proper HTML span.'
269269
);
270270

0 commit comments

Comments
 (0)