From e71c3c7f0177b5d360fcf0827d278a5db98ee7b9 Mon Sep 17 00:00:00 2001 From: Greg Marshall Date: Thu, 28 Mar 2024 07:49:56 -0500 Subject: [PATCH 1/4] WIP: issue-19 From b5e7ffb0044f51823d9ceaab35347952264babab Mon Sep 17 00:00:00 2001 From: Greg Marshall Date: Thu, 28 Mar 2024 07:50:21 -0500 Subject: [PATCH 2/4] preserve new lines in embed blocks --- CHANGELOG.md | 4 ++++ src/class-block-converter.php | 10 ++++++++-- tests/feature/test-block-converter.php | 24 ++++++++++++++++++------ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2378772..71eb60c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `WP Block Converter` will be documented in this file. +## 1.3.2 + +- Preserve new lines in embed blocks. They are required for proper front end rendering. + ## 1.3.1 - Fixes embeds of x.com urls (instead of twitter.com) diff --git a/src/class-block-converter.php b/src/class-block-converter.php index cac77da..94f505f 100644 --- a/src/class-block-converter.php +++ b/src/class-block-converter.php @@ -67,6 +67,7 @@ public function convert(): string { } // Merge the block into the HTML collection. + $html[] = $this->minify_block( (string) $tag_block ); } @@ -446,8 +447,13 @@ public static function get_node_tag_from_html( $html, $tag = 'body' ) { * @return string */ protected function minify_block( $block ) { - if ( preg_match( '/(\s){2,}/s', $block ) === 1 ) { - return preg_replace( '/(\s){2,}/s', '', $block ); + if ( \str_contains( $block, 'wp-block-embed' ) ) { + $pattern = '/(\h){2,}/s'; + } else { + $pattern = '/(\s){2,}/s'; + } + if ( preg_match( $pattern, $block ) === 1 ) { + return preg_replace( $pattern, '', $block ); } return $block; diff --git a/tests/feature/test-block-converter.php b/tests/feature/test-block-converter.php index 71b08c7..fd5b232 100644 --- a/tests/feature/test-block-converter.php +++ b/tests/feature/test-block-converter.php @@ -169,7 +169,9 @@ public function test_youtube_url_to_embed() { $this->assertNotEmpty( $block ); $this->assertSame( - '
https://www.youtube.com/watch?v=dQw4w9WgXcQ
', + '
+https://www.youtube.com/watch?v=dQw4w9WgXcQ +
', $block, ); } @@ -184,7 +186,9 @@ public function test_twitter_url_to_embed() { $this->assertNotEmpty( $block ); $this->assertSame( - '
https://twitter.com/alleyco/status/1679189879086018562
', + '
+https://twitter.com/alleyco/status/1679189879086018562 +
', $block, ); } @@ -199,7 +203,9 @@ public function test_x_url_to_embed() { $this->assertNotEmpty( $block ); $this->assertSame( - '
https://twitter.com/alleyco/status/1679189879086018562
', + '
+https://twitter.com/alleyco/status/1679189879086018562 +
', $block, ); } @@ -214,7 +220,9 @@ public function test_linked_x_url_to_embed() { $this->assertNotEmpty( $block ); $this->assertSame( - '
https://twitter.com/alleyco/status/1679189879086018562
', + '
+https://twitter.com/alleyco/status/1679189879086018562 +
', $block, ); } @@ -225,7 +233,9 @@ public function test_instagram_url_to_embed() { $this->assertNotEmpty( $block ); $this->assertSame( - '
https://www.instagram.com/p/CSpmSvAphdf/
', + '
+https://www.instagram.com/p/CSpmSvAphdf/ +
', $block, ); } @@ -236,7 +246,9 @@ public function test_facebook_url_to_embed() { $this->assertNotEmpty( $block ); $this->assertSame( - '
https://www.facebook.com/sesametheopossum/posts/1329405240877426
', + '
+https://www.facebook.com/sesametheopossum/posts/1329405240877426 +
', $block, ); } From 30fb062f684809d5a2a7d8b6ed27e0e4676ef868 Mon Sep 17 00:00:00 2001 From: Greg Marshall Date: Thu, 28 Mar 2024 07:50:41 -0500 Subject: [PATCH 3/4] Ready for review From 385ba6d3cbd346ae85ccce4be09c402b86536ae3 Mon Sep 17 00:00:00 2001 From: Greg Marshall Date: Thu, 28 Mar 2024 08:13:16 -0500 Subject: [PATCH 4/4] fix tiktok support --- CHANGELOG.md | 1 + src/class-block-converter.php | 2 +- tests/feature/test-block-converter.php | 269 +++++++++++++------------ 3 files changed, 143 insertions(+), 129 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71eb60c..38af142 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to `WP Block Converter` will be documented in this file. ## 1.3.2 - Preserve new lines in embed blocks. They are required for proper front end rendering. +- Fix aspect ratio calculation when height and width are percentages - which fixes TikTok embeds. ## 1.3.1 diff --git a/src/class-block-converter.php b/src/class-block-converter.php index 94f505f..07a42cc 100644 --- a/src/class-block-converter.php +++ b/src/class-block-converter.php @@ -275,7 +275,7 @@ protected function embed( string $url ): Block { $data = _wp_oembed_get_object()->get_data( $url, [] ); $aspect_ratio = ''; - if ( ! empty( $data->height ) && ! empty( $data->width ) ) { + if ( ! empty( $data->height ) && ! empty( $data->width ) && is_numeric( $data->height ) && is_numeric( $data->width ) ) { if ( 1.78 === round( $data->width / $data->height, 2 ) ) { $aspect_ratio = '16-9'; } diff --git a/tests/feature/test-block-converter.php b/tests/feature/test-block-converter.php index fd5b232..a60d5db 100644 --- a/tests/feature/test-block-converter.php +++ b/tests/feature/test-block-converter.php @@ -18,103 +18,103 @@ * @group block */ class Test_Block_Block_Converter extends Test_Case { - public function test_convert_content_to_blocks() { - $html = '

Content to migrate

Heading 01

'; - $converter = new Block_Converter( $html ); - $block = $converter->convert(); + public function test_convert_content_to_blocks() { + $html = '

Content to migrate

Heading 01

'; + $converter = new Block_Converter( $html ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertEquals( + $this->assertNotEmpty( $block ); + $this->assertEquals( '

Content to migrate

Heading 01

', $block, - ); - } + ); + } - public function test_convert_heading_h1_to_block() { - $html = '

Another content

'; - $converter = new Block_Converter( $html ); - $block = $converter->convert(); + public function test_convert_heading_h1_to_block() { + $html = '

Another content

'; + $converter = new Block_Converter( $html ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( + $this->assertNotEmpty( $block ); + $this->assertSame( '' . $html . '', - $block, - ); - } + $block, + ); + } - public function test_convert_heading_h2_to_block() { - $html = '

Another content

'; - $converter = new Block_Converter( $html ); - $block = $converter->convert(); + public function test_convert_heading_h2_to_block() { + $html = '

Another content

'; + $converter = new Block_Converter( $html ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( + $this->assertNotEmpty( $block ); + $this->assertSame( '' . $html . '', $block, - ); - } + ); + } - public function test_convert_ol_to_block() { - $html = '
  1. Random content
  2. Another random content
'; - $converter = new Block_Converter( $html ); - $block = $converter->convert(); + public function test_convert_ol_to_block() { + $html = '
  1. Random content
  2. Another random content
'; + $converter = new Block_Converter( $html ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( + $this->assertNotEmpty( $block ); + $this->assertSame( '' . $html . '', $block, ); - } + } - public function test_convert_ul_to_block() { - $html = '
  • Random content
  • Another random content
'; - $converter = new Block_Converter( $html ); - $block = $converter->convert(); + public function test_convert_ul_to_block() { + $html = '
  • Random content
  • Another random content
'; + $converter = new Block_Converter( $html ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( + $this->assertNotEmpty( $block ); + $this->assertSame( "{$html}", $block, - ); - } + ); + } - public function test_convert_paragraphs_to_block() { - $converter = new Block_Converter( '

bar

' ); - $block = $converter->convert(); + public function test_convert_paragraphs_to_block() { + $converter = new Block_Converter( '

bar

' ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( + $this->assertNotEmpty( $block ); + $this->assertSame( '

bar

', $block, - ); - } + ); + } - public function test_convert_with_empty_paragraphs_to_block() { - $converter = new Block_Converter( '

bar

' ); - $block = $converter->convert(); + public function test_convert_with_empty_paragraphs_to_block() { + $converter = new Block_Converter( '

bar

' ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( - '

bar

', + $this->assertNotEmpty( $block ); + $this->assertSame( + '

bar

', $block, - ); - } + ); + } - public function test_convert_with_empty_paragraphs_of_arbitrary_length_to_block() { - $arbitraryNewLines = str_repeat( "\n\r", mt_rand( 1, 1000) ); - $arbitrarySpaces = str_repeat( " ", mt_rand( 1, 1000 ) ); + public function test_convert_with_empty_paragraphs_of_arbitrary_length_to_block() { + $arbitraryNewLines = str_repeat( "\n\r", mt_rand( 1, 1000) ); + $arbitrarySpaces = str_repeat( " ", mt_rand( 1, 1000 ) ); - $converter = new Block_Converter( '

bar

' . $arbitrarySpaces . $arbitraryNewLines . '

' ); - $block = $converter->convert(); + $converter = new Block_Converter( '

bar

' . $arbitrarySpaces . $arbitraryNewLines . '

' ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( + $this->assertNotEmpty( $block ); + $this->assertSame( $block, '

bar

', - ); - } + ); + } public function test_convert_with_filter_override_single_tag() { $this->expectApplied( 'wp_block_converter_document_html' )->once(); @@ -159,99 +159,112 @@ public function test_convert_with_filter_override_entire_content() { $this->assertSame( 'Override', $block ); } - public function test_youtube_url_to_embed() { - $this->fake_request( 'https://www.youtube.com/oembed?maxwidth=500&maxheight=750&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdQw4w9WgXcQ&dnt=1&format=json' ) - ->with_response_code( 200 ) - ->with_body( '{"title":"Rick Astley - Never Gonna Give You Up (Official Music Video)","author_name":"Rick Astley","author_url":"https://www.youtube.com/@RickAstleyYT","type":"video","height":281,"width":500,"version":"1.0","provider_name":"YouTube","provider_url":"https://www.youtube.com/","thumbnail_height":360,"thumbnail_width":480,"thumbnail_url":"https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg","html":"\u003ciframe width=\u0022500\u0022 height=\u0022281\u0022 src=\u0022https://www.youtube.com/embed/dQw4w9WgXcQ?feature=oembed\u0022 frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\u0022 allowfullscreen title=\u0022Rick Astley - Never Gonna Give You Up (Official Music Video)\u0022\u003e\u003c/iframe\u003e"}' ); + public function test_youtube_url_to_embed() { + $this->fake_request( 'https://www.youtube.com/oembed?maxwidth=500&maxheight=750&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdQw4w9WgXcQ&dnt=1&format=json' ) + ->with_response_code( 200 ) + ->with_body( '{"title":"Rick Astley - Never Gonna Give You Up (Official Music Video)","author_name":"Rick Astley","author_url":"https://www.youtube.com/@RickAstleyYT","type":"video","height":281,"width":500,"version":"1.0","provider_name":"YouTube","provider_url":"https://www.youtube.com/","thumbnail_height":360,"thumbnail_width":480,"thumbnail_url":"https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg","html":"\u003ciframe width=\u0022500\u0022 height=\u0022281\u0022 src=\u0022https://www.youtube.com/embed/dQw4w9WgXcQ?feature=oembed\u0022 frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\u0022 allowfullscreen title=\u0022Rick Astley - Never Gonna Give You Up (Official Music Video)\u0022\u003e\u003c/iframe\u003e"}' ); - $converter = new Block_Converter( '

https://www.youtube.com/watch?v=dQw4w9WgXcQ

' ); - $block = $converter->convert(); + $converter = new Block_Converter( '

https://www.youtube.com/watch?v=dQw4w9WgXcQ

' ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( + $this->assertNotEmpty( $block ); + $this->assertSame( '
https://www.youtube.com/watch?v=dQw4w9WgXcQ
', $block, - ); - } + ); + } - public function test_twitter_url_to_embed() { - $this->fake_request( 'https://publish.twitter.com/oembed?maxwidth=500&maxheight=750&url=https%3A%2F%2Ftwitter.com%2Falleyco%2Fstatus%2F1679189879086018562&dnt=1&format=json' ) - ->with_response_code( 200 ) - ->with_body( '{"url":"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562","author_name":"Alley","author_url":"https:\/\/twitter.com\/alleyco","html":"\u003Cblockquote class=\"twitter-tweet\"\u003E\u003Cp lang=\"en\" dir=\"ltr\"\u003EWe’re a full-service digital agency with the foresight, perspective, and grit to power your brightest ideas and build solutions for your most evasive problems. Learn more about our services here:\u003Ca href=\"https:\/\/t.co\/8zZ5zP1Oyc\"\u003Ehttps:\/\/t.co\/8zZ5zP1Oyc\u003C\/a\u003E\u003C\/p\u003E— Alley (@alleyco) \u003Ca href=\"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562?ref_src=twsrc%5Etfw\"\u003EJuly 12, 2023\u003C\/a\u003E\u003C\/blockquote\u003E\n\u003Cscript async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"\u003E\u003C\/script\u003E\n\n","width":550,"height":null,"type":"rich","cache_age":"3153600000","provider_name":"Twitter","provider_url":"https:\/\/twitter.com","version":"1.0"}' ); + public function test_twitter_url_to_embed() { + $this->fake_request( 'https://publish.twitter.com/oembed?maxwidth=500&maxheight=750&url=https%3A%2F%2Ftwitter.com%2Falleyco%2Fstatus%2F1679189879086018562&dnt=1&format=json' ) + ->with_response_code( 200 ) + ->with_body( '{"url":"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562","author_name":"Alley","author_url":"https:\/\/twitter.com\/alleyco","html":"\u003Cblockquote class=\"twitter-tweet\"\u003E\u003Cp lang=\"en\" dir=\"ltr\"\u003EWe’re a full-service digital agency with the foresight, perspective, and grit to power your brightest ideas and build solutions for your most evasive problems. Learn more about our services here:\u003Ca href=\"https:\/\/t.co\/8zZ5zP1Oyc\"\u003Ehttps:\/\/t.co\/8zZ5zP1Oyc\u003C\/a\u003E\u003C\/p\u003E— Alley (@alleyco) \u003Ca href=\"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562?ref_src=twsrc%5Etfw\"\u003EJuly 12, 2023\u003C\/a\u003E\u003C\/blockquote\u003E\n\u003Cscript async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"\u003E\u003C\/script\u003E\n\n","width":550,"height":null,"type":"rich","cache_age":"3153600000","provider_name":"Twitter","provider_url":"https:\/\/twitter.com","version":"1.0"}' ); - $converter = new Block_Converter( '

https://twitter.com/alleyco/status/1679189879086018562

' ); - $block = $converter->convert(); + $converter = new Block_Converter( '

https://twitter.com/alleyco/status/1679189879086018562

' ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( - '
+ $this->assertNotEmpty( $block ); + $this->assertSame( + '
https://twitter.com/alleyco/status/1679189879086018562
', - $block, - ); - } + $block, + ); + } - public function test_x_url_to_embed() { - $this->fake_request( 'https://publish.x.com/oembed?url=https%3A%2F%2Fx.com%2Falleyco%2Fstatus%2F1679189879086018562' ) - ->with_response_code( 200 ) - ->with_body( '{"url":"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562","author_name":"Alley","author_url":"https:\/\/twitter.com\/alleyco","html":"\u003Cblockquote class=\"twitter-tweet\"\u003E\u003Cp lang=\"en\" dir=\"ltr\"\u003EWe’re a full-service digital agency with the foresight, perspective, and grit to power your brightest ideas and build solutions for your most evasive problems. Learn more about our services here:\u003Ca href=\"https:\/\/t.co\/8zZ5zP1Oyc\"\u003Ehttps:\/\/t.co\/8zZ5zP1Oyc\u003C\/a\u003E\u003C\/p\u003E— Alley (@alleyco) \u003Ca href=\"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562?ref_src=twsrc%5Etfw\"\u003EJuly 12, 2023\u003C\/a\u003E\u003C\/blockquote\u003E\n\u003Cscript async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"\u003E\u003C\/script\u003E\n\n","width":550,"height":null,"type":"rich","cache_age":"3153600000","provider_name":"Twitter","provider_url":"https:\/\/twitter.com","version":"1.0"}' ); + public function test_x_url_to_embed() { + $this->fake_request( 'https://publish.x.com/oembed?url=https%3A%2F%2Fx.com%2Falleyco%2Fstatus%2F1679189879086018562' ) + ->with_response_code( 200 ) + ->with_body( '{"url":"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562","author_name":"Alley","author_url":"https:\/\/twitter.com\/alleyco","html":"\u003Cblockquote class=\"twitter-tweet\"\u003E\u003Cp lang=\"en\" dir=\"ltr\"\u003EWe’re a full-service digital agency with the foresight, perspective, and grit to power your brightest ideas and build solutions for your most evasive problems. Learn more about our services here:\u003Ca href=\"https:\/\/t.co\/8zZ5zP1Oyc\"\u003Ehttps:\/\/t.co\/8zZ5zP1Oyc\u003C\/a\u003E\u003C\/p\u003E— Alley (@alleyco) \u003Ca href=\"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562?ref_src=twsrc%5Etfw\"\u003EJuly 12, 2023\u003C\/a\u003E\u003C\/blockquote\u003E\n\u003Cscript async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"\u003E\u003C\/script\u003E\n\n","width":550,"height":null,"type":"rich","cache_age":"3153600000","provider_name":"Twitter","provider_url":"https:\/\/twitter.com","version":"1.0"}' ); - $converter = new Block_Converter( '

https://x.com/alleyco/status/1679189879086018562

' ); - $block = $converter->convert(); + $converter = new Block_Converter( '

https://x.com/alleyco/status/1679189879086018562

' ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( - '
+ $this->assertNotEmpty( $block ); + $this->assertSame( + '
https://twitter.com/alleyco/status/1679189879086018562
', - $block, - ); - } + $block, + ); + } - public function test_linked_x_url_to_embed() { - $this->fake_request( 'https://publish.x.com/oembed?url=https%3A%2F%2Fx.com%2Falleyco%2Fstatus%2F1679189879086018562' ) - ->with_response_code( 200 ) - ->with_body( '{"url":"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562","author_name":"Alley","author_url":"https:\/\/twitter.com\/alleyco","html":"\u003Cblockquote class=\"twitter-tweet\"\u003E\u003Cp lang=\"en\" dir=\"ltr\"\u003EWe’re a full-service digital agency with the foresight, perspective, and grit to power your brightest ideas and build solutions for your most evasive problems. Learn more about our services here:\u003Ca href=\"https:\/\/t.co\/8zZ5zP1Oyc\"\u003Ehttps:\/\/t.co\/8zZ5zP1Oyc\u003C\/a\u003E\u003C\/p\u003E— Alley (@alleyco) \u003Ca href=\"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562?ref_src=twsrc%5Etfw\"\u003EJuly 12, 2023\u003C\/a\u003E\u003C\/blockquote\u003E\n\u003Cscript async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"\u003E\u003C\/script\u003E\n\n","width":550,"height":null,"type":"rich","cache_age":"3153600000","provider_name":"Twitter","provider_url":"https:\/\/twitter.com","version":"1.0"}' ); + public function test_linked_x_url_to_embed() { + $this->fake_request( 'https://publish.x.com/oembed?url=https%3A%2F%2Fx.com%2Falleyco%2Fstatus%2F1679189879086018562' ) + ->with_response_code( 200 ) + ->with_body( '{"url":"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562","author_name":"Alley","author_url":"https:\/\/twitter.com\/alleyco","html":"\u003Cblockquote class=\"twitter-tweet\"\u003E\u003Cp lang=\"en\" dir=\"ltr\"\u003EWe’re a full-service digital agency with the foresight, perspective, and grit to power your brightest ideas and build solutions for your most evasive problems. Learn more about our services here:\u003Ca href=\"https:\/\/t.co\/8zZ5zP1Oyc\"\u003Ehttps:\/\/t.co\/8zZ5zP1Oyc\u003C\/a\u003E\u003C\/p\u003E— Alley (@alleyco) \u003Ca href=\"https:\/\/twitter.com\/alleyco\/status\/1679189879086018562?ref_src=twsrc%5Etfw\"\u003EJuly 12, 2023\u003C\/a\u003E\u003C\/blockquote\u003E\n\u003Cscript async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"\u003E\u003C\/script\u003E\n\n","width":550,"height":null,"type":"rich","cache_age":"3153600000","provider_name":"Twitter","provider_url":"https:\/\/twitter.com","version":"1.0"}' ); - $converter = new Block_Converter( '

https://x.com/alleyco/status/1679189879086018562

' ); - $block = $converter->convert(); + $converter = new Block_Converter( '

https://x.com/alleyco/status/1679189879086018562

' ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( - '
+ $this->assertNotEmpty( $block ); + $this->assertSame( + '
https://twitter.com/alleyco/status/1679189879086018562
', - $block, - ); - } + $block, + ); + } - public function test_instagram_url_to_embed() { - $converter = new Block_Converter( '

https://www.instagram.com/p/CSpmSvAphdf/

' ); - $block = $converter->convert(); + public function test_instagram_url_to_embed() { + $converter = new Block_Converter( '

https://www.instagram.com/p/CSpmSvAphdf/

' ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( - '
+ $this->assertNotEmpty( $block ); + $this->assertSame( + '
https://www.instagram.com/p/CSpmSvAphdf/
', - $block, - ); - } + $block, + ); + } - public function test_facebook_url_to_embed() { - $converter = new Block_Converter( '

https://www.facebook.com/sesametheopossum/posts/1329405240877426

' ); - $block = $converter->convert(); + public function test_facebook_url_to_embed() { + $converter = new Block_Converter( '

https://www.facebook.com/sesametheopossum/posts/1329405240877426

' ); + $block = $converter->convert(); - $this->assertNotEmpty( $block ); - $this->assertSame( - '
+ $this->assertNotEmpty( $block ); + $this->assertSame( + '
https://www.facebook.com/sesametheopossum/posts/1329405240877426
', - $block, - ); - } + $block, + ); + } + + public function test_tiktok_url_to_embed() { + $converter = new Block_Converter( '

https://www.tiktok.com/@atribecalledval/video/7348705314746699054

' ); + $block = $converter->convert(); + + $this->assertNotEmpty( $block ); + $this->assertSame( + '
+https://www.tiktok.com/@atribecalledval/video/7348705314746699054 +
', + $block, + ); + } public function test_macroable() { Block_Converter::macro(