From ecf19457266025a834bc55ba75f300c01d079de6 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Tue, 18 Feb 2025 12:44:32 -0500 Subject: [PATCH] Ensure cite does not get stripped --- src/class-block-converter.php | 7 ++++++- tests/feature/BlockConverterTest.php | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/class-block-converter.php b/src/class-block-converter.php index cdb122e..84384eb 100644 --- a/src/class-block-converter.php +++ b/src/class-block-converter.php @@ -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 ), }; @@ -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 ) ) { diff --git a/tests/feature/BlockConverterTest.php b/tests/feature/BlockConverterTest.php index 7388ae3..ee55dec 100644 --- a/tests/feature/BlockConverterTest.php +++ b/tests/feature/BlockConverterTest.php @@ -92,6 +92,10 @@ public static function converter_data_provider() { '

Lorem ipsum

', '

Lorem ipsum

', ], + 'blockquote with cite' => [ + '

Lorem ipsum

Source
', + '

Lorem ipsum

Source
', + ], 'non-oembed-embed' => [ '', '',