Skip to content

Commit 6b5fe21

Browse files
committed
Handle self closing tags
1 parent bf603a9 commit 6b5fe21

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

includes/create-theme/theme-token-processor.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ public function __construct( $string ) {
2626
*/
2727
public function process_tokens() {
2828
while ( $this->p->next_token() ) {
29-
$token_type = $this->p->get_token_type();
30-
$token_name = strtolower( $this->p->get_token_name() );
31-
$is_tag_closer = $this->p->is_tag_closer();
29+
$token_type = $this->p->get_token_type();
30+
$token_name = strtolower( $this->p->get_token_name() );
31+
$is_tag_closer = $this->p->is_tag_closer();
32+
$has_self_closer = $this->p->has_self_closing_flag();
3233

3334
if ( '#tag' === $token_type ) {
3435
$this->increment++;
@@ -51,9 +52,14 @@ public function process_tokens() {
5152
$token .= $this->process_attribute( $attr_name, $attr_value );
5253
}
5354

54-
$token .= '>';
55-
$this->tokens[] = $token;
56-
$this->translators_note .= $token_label . " is the start of a '" . $token_name . "' HTML element";
55+
$token .= '>';
56+
$this->tokens[] = $token;
57+
58+
if ( $has_self_closer || 'br' === $token_name ) {
59+
$this->translators_note .= $token_label . " is a '" . $token_name . "' HTML element";
60+
} else {
61+
$this->translators_note .= $token_label . " is the start of a '" . $token_name . "' HTML element";
62+
}
5763
}
5864
} else {
5965
// Escape text content.

0 commit comments

Comments
 (0)