WP_HTML_Processor::step_in_caption
Parses next element in the 'in caption' insertion mode.
This internal function performs the 'in caption' insertion mode logic for the generalized WP_HTML_Processor::step() function.
Method of the class: WP_HTML_Processor{}
No Hooks.
Returns
true|false. Whether an element was found.
Usage
// private - for code of main (parent) class only $result = $this->step_in_caption(): bool;
Notes
Changelog
| Since 6.7.0 | Introduced. |
WP_HTML_Processor::step_in_caption() WP HTML Processor::step in caption code WP 6.9
private function step_in_caption(): bool {
$tag_name = $this->get_tag();
$op_sigil = $this->is_tag_closer() ? '-' : '+';
$op = "{$op_sigil}{$tag_name}";
switch ( $op ) {
/*
* > An end tag whose tag name is "caption"
* > A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"
* > An end tag whose tag name is "table"
*
* These tag handling rules are identical except for the final instruction.
* Handle them in a single block.
*/
case '-CAPTION':
case '+CAPTION':
case '+COL':
case '+COLGROUP':
case '+TBODY':
case '+TD':
case '+TFOOT':
case '+TH':
case '+THEAD':
case '+TR':
case '-TABLE':
if ( ! $this->state->stack_of_open_elements->has_element_in_table_scope( 'CAPTION' ) ) {
// Parse error: ignore the token.
return $this->step();
}
$this->generate_implied_end_tags();
if ( ! $this->state->stack_of_open_elements->current_node_is( 'CAPTION' ) ) {
// @todo Indicate a parse error once it's possible.
}
$this->state->stack_of_open_elements->pop_until( 'CAPTION' );
$this->state->active_formatting_elements->clear_up_to_last_marker();
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_TABLE;
// If this is not a CAPTION end tag, the token should be reprocessed.
if ( '-CAPTION' === $op ) {
return true;
}
return $this->step( self::REPROCESS_CURRENT_NODE );
/**
* > An end tag whose tag name is one of: "body", "col", "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr"
*/
case '-BODY':
case '-COL':
case '-COLGROUP':
case '-HTML':
case '-TBODY':
case '-TD':
case '-TFOOT':
case '-TH':
case '-THEAD':
case '-TR':
// Parse error: ignore the token.
return $this->step();
}
/**
* > Anything else
* > Process the token using the rules for the "in body" insertion mode.
*/
return $this->step_in_body();
}