dirs = $this->initDirs();
parent::__construct($name, $data, $dataName);
}
/** @var string[] */
private $dirs;
/**
* @return string[]
*/
protected function initDirs()
{
return [\dirname(__FILE__).'/data/'];
}
/**
* @dataProvider data
* @param string $test
* @param string $dir
* @return void
* @throws \PHPUnit\Framework\ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function test_($test, $dir)
{
$markdown = \file_get_contents($dir . $test . '.md');
$expectedMarkup = \file_get_contents($dir . $test . '.html');
$expectedMarkup = \str_replace("\r\n", "\n", $expectedMarkup);
$expectedMarkup = \str_replace("\r", "\n", $expectedMarkup);
$Parsedown = new Parsedown(new State([
new SafeMode(\substr($test, 0, 3) === 'xss'),
new StrictMode(\substr($test, 0, 6) === 'strict'),
new Breaks(\substr($test, 0, 14) === 'breaks_enabled'),
new HeaderSlug(\substr($test, 0, 4) === 'slug'),
]));
$actualMarkup = $Parsedown->toHtml($markdown);
$this->assertEquals($expectedMarkup, $actualMarkup);
}
/** @return array
sparse:
<div> <div class="inner"> content </div> </div>
paragraph
<style type="text/css"> p { color: red; } </style>
comment
<!-- html comment -->
EXPECTED_HTML; $parsedownWithNoMarkup = new Parsedown(new State([ BlockTypes::initial()->removing([BlockMarkup::class]), InlineTypes::initial()->removing([InlineMarkup::class]), ])); $this->assertEquals($expectedHtml, $parsedownWithNoMarkup->toHtml($markdownWithHtml)); } }