and uAfrica.com (http://uafrica.com) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace League\CommonMark\Tests\Functional\Extension\Strikethrough; use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\Extension\Strikethrough\StrikethroughExtension; use League\CommonMark\Parser\MarkdownParser; use League\CommonMark\Renderer\HtmlRenderer; use PHPUnit\Framework\TestCase; final class StrikethroughExtensionTest extends TestCase { /** * @dataProvider dataForIntegrationTest */ public function testStrikethrough(string $string, string $expected): void { $environment = new Environment(); $environment->addExtension(new CommonMarkCoreExtension()); $environment->addExtension(new StrikethroughExtension()); $parser = new MarkdownParser($environment); $renderer = new HtmlRenderer($environment); $document = $parser->parse($string); $html = (string) $renderer->renderDocument($document); $this->assertSame($expected, $html); } /** * @return array> */ public function dataForIntegrationTest(): array { return [ ['~~Hi~~ Hello, ~there~ world!', "

Hi Hello, there world!

\n"], ['This is a test without any strikethroughs', "

This is a test without any strikethroughs

\n"], ['This is a test with ~valid~ strikethroughs', "

This is a test with valid strikethroughs

\n"], ['This is a test `with` ~valid~ strikethroughs', "

This is a test with valid strikethroughs

\n"], ['This is a ~~unit~~ integration test', "

This is a unit integration test

\n"], ['~~Strikethrough~~ on the left', "

Strikethrough on the left

\n"], ['Strikethrough on the ~~right~~', "

Strikethrough on the right

\n"], ['~~Strikethrough everywhere~~', "

Strikethrough everywhere

\n"], ['This ~~test has no ending match', "

This ~~test has no ending match

\n"], ['This ~~test~~~ has mismatched tildes', "

This ~~test~~~ has mismatched tildes

\n"], ['This ~~~test~~ also has mismatched tildes', "

This ~~~test~~ also has mismatched tildes

\n"], ['This one has ~~~three~~~ tildes', "

This one has ~~~three~~~ tildes

\n"], ["This ~~has a\n\nnew paragraph~~.", "

This ~~has a

\n

new paragraph~~.

\n"], ['Hello ~~ ~~ world', "

Hello ~~ ~~ world

\n"], ['This **is ~~a little** test of mismatched delimiters~~', "

This is ~~a little test of mismatched delimiters~~

\n"], ['Из: твоя ~~тест~~ ветка', "

Из: твоя тест ветка

\n"], ['This one combines ~~nested ~~strikethrough~~ text~~', "

This one combines nested strikethrough text

\n"], ['Here we have **emphasized text containing a ~~strikethrough~~**', "

Here we have emphasized text containing a strikethrough

\n"], ['Four trailing tildes ~~~~', "

Four trailing tildes ~~~~

\n"], ['~~Unmatched left', "

~~Unmatched left

\n"], ['Unmatched right~~', "

Unmatched right~~

\n"], ['~~foo~bar~~', "

foo~bar

\n"], ['~~foo~~bar~~', "

foobar~~

\n"], ['~~foo~~~bar~~', "

foo~~~bar

\n"], ['~~foo~~~~bar~~', "

foo~~~~bar

\n"], ['~~foo~~~~~bar~~', "

foo~~~~~bar

\n"], ['~~foo~~~~~~bar~~', "

foo~~~~~~bar

\n"], ['~~foo~~~~~~~bar~~', "

foo~~~~~~~bar

\n"], ['> inside a ~~blockquote~~', "
\n

inside a blockquote

\n
\n"], ]; } }