textLevelElementRegex = '\b(?:' . \implode('|', $textLevelElements) . ')\b'; parent::__construct($name, $data, $dataName); } /** * @dataProvider data * @param int $_ * @param string $__ * @param string $markdown * @param string $expectedHtml * @return void * @throws \PHPUnit\Framework\AssertionFailedError * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ public function testExample($_, $__, $markdown, $expectedHtml) { $expectedHtml = $this->cleanupHtml($expectedHtml); $actualHtml = $this->Parsedown->toHtml($markdown); $actualHtml = $this->cleanupHtml($actualHtml); $this->assertEquals($expectedHtml, $actualHtml); } /** * @param string $markup * @return string */ protected function cleanupHtml($markup) { // invisible whitespaces at the beginning and end of block elements // however, whitespaces at the beginning of
 elements do matter
        $markup = \preg_replace(
            [
                '/(<(?!(?:' . $this->textLevelElementRegex . '|\bpre\b))\w+\b[^>]*>(?:<' . $this->textLevelElementRegex . '[^>]*>)*)\s+/s',
                '/\s+((?:<\/' . $this->textLevelElementRegex . '>)*<\/(?!' . $this->textLevelElementRegex . ')\w+\b>)/s'
            ],
            '$1',
            $markup
        );

        return $markup;
    }
}