Skip to content

Commit

Permalink
Ensure cite does not get stripped
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher committed Feb 18, 2025
1 parent 4d8f41d commit ecf1945
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/class-block-converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function convert_node( DOMNode $node ): ?Block {
'h1', 'h2', 'h3', 'h4', 'h5', 'h6' => $this->h( $node ),
'p', 'a', 'abbr', 'b', 'code', 'em', 'i', 'strong', 'sub', 'sup', 'span', 'u' => $this->p( $node ),
'figure' => $this->figure( $node ),
'br', 'cite', 'source' => null,
'br', 'source', 'cite' => null,
'hr' => $this->separator(),
default => $this->html( $node ),
};
Expand Down Expand Up @@ -214,6 +214,11 @@ public function convert_with_children( DOMNode $node ): string {
continue;
}

// Ensure that the cite tag is not converted to a block.
if ( 'cite' === strtolower( $child->nodeName ) ) {
$children .= trim( static::get_node_html( $child ) );
}

$child_block = $this->convert_node( $child );

if ( ! empty( $child_block ) ) {
Expand Down
4 changes: 4 additions & 0 deletions tests/feature/BlockConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public static function converter_data_provider() {
'<blockquote><p>Lorem ipsum</p></blockquote>',
'<!-- wp:quote --><blockquote class="wp-block-quote"><!-- wp:paragraph --><p>Lorem ipsum</p><!-- /wp:paragraph --></blockquote><!-- /wp:quote -->',
],
'blockquote with cite' => [
'<blockquote><p>Lorem ipsum</p><cite>Source</cite></blockquote>',
'<!-- wp:quote --><blockquote class="wp-block-quote"><!-- wp:paragraph --><p>Lorem ipsum</p><!-- /wp:paragraph --><cite>Source</cite></blockquote><!-- /wp:quote -->',
],
'non-oembed-embed' => [
'<embed type="video/webm" src="/media/mr-arnold.mp4" width="250" height="200" />',
'<!-- wp:html --><embed type="video/webm" src="/media/mr-arnold.mp4" width="250" height="200"></embed><!-- /wp:html -->',
Expand Down

0 comments on commit ecf1945

Please sign in to comment.