WP_HTML_Processor::is_special( string $tag_name ): bool

Returns whether an element of a given name is in the HTML special category.

Description

See also

Parameters

$tag_namestringrequired
Name of element to check.

Return

bool Whether the element of the given name is in the special category.

Source


	return true;

/*
 * > A start tag whose tag name is "li"
 * > A start tag whose tag name is one of: "dd", "dt"
 */
case '+DD':
case '+DT':
case '+LI':
	$this->state->frameset_ok = false;
	$node                     = $this->state->stack_of_open_elements->current_node();
	$is_li                    = 'LI' === $token_name;

	in_body_list_loop:
	/*
	 * The logic for LI and DT/DD is the same except for one point: LI elements _only_
	 * close other LI elements, but a DT or DD element closes _any_ open DT or DD element.
	 */
	if ( $is_li ? 'LI' === $node->node_name : ( 'DD' === $node->node_name || 'DT' === $node->node_name ) ) {
		$node_name = $is_li ? 'LI' : $node->node_name;
		$this->generate_implied_end_tags( $node_name );
		if ( ! $this->state->stack_of_open_elements->current_node_is( $node_name ) ) {
			// @todo Indicate a parse error once it's possible. This error does not impact the logic here.
		}

		$this->state->stack_of_open_elements->pop_until( $node_name );
		goto in_body_list_done;
	}

	if (
		'ADDRESS' !== $node->node_name &&
		'DIV' !== $node->node_name &&
		'P' !== $node->node_name &&
		self::is_special( $node )
	) {
		/*
		 * > If node is in the special category, but is not an address, div,
		 * > or p element, then jump to the step labeled done below.
		 */
		goto in_body_list_done;
	} else {
		/*
		 * > Otherwise, set node to the previous entry in the stack of open elements
		 * > and return to the step labeled loop.
		 */
		foreach ( $this->state->stack_of_open_elements->walk_up( $node ) as $item ) {
			$node = $item;
			break;
		}
		goto in_body_list_loop;
	}

	in_body_list_done:
	if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
		$this->close_a_p_element();
	}

	$this->insert_html_element( $this->state->current_token );
	return true;

case '+PLAINTEXT':
	if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
		$this->close_a_p_element();
	}

	/*
	 * @todo This may need to be handled in the Tag Processor and turn into
	 *       a single self-contained tag like TEXTAREA, whose modifiable text
	 *       is the rest of the input document as plaintext.
	 */
	$this->bail( 'Cannot process PLAINTEXT elements.' );
	break;

/*
 * > A start tag whose tag name is "button"
 */
case '+BUTTON':
	if ( $this->state->stack_of_open_elements->has_element_in_scope( 'BUTTON' ) ) {
		// @todo Indicate a parse error once it's possible. This error does not impact the logic here.
		$this->generate_implied_end_tags();
		$this->state->stack_of_open_elements->pop_until( 'BUTTON' );
	}

	$this->reconstruct_active_formatting_elements();
	$this->insert_html_element( $this->state->current_token );
	$this->state->frameset_ok = false;

	return true;

/*
 * > An end tag whose tag name is one of: "address", "article", "aside", "blockquote",
 * > "button", "center", "details", "dialog", "dir", "div", "dl", "fieldset",
 * > "figcaption", "figure", "footer", "header", "hgroup", "listing", "main",
 * > "menu", "nav", "ol", "pre", "search", "section", "summary", "ul"
 */
case '-ADDRESS':
case '-ARTICLE':
case '-ASIDE':
case '-BLOCKQUOTE':
case '-BUTTON':
case '-CENTER':

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.