diff --git a/ParsedownExtra.php b/ParsedownExtra.php index be6966d..265ac2b 100644 --- a/ParsedownExtra.php +++ b/ParsedownExtra.php @@ -43,6 +43,7 @@ function __construct() function text($text) { + $this->footnoteCount = 0; $markup = parent::text($text); # merge consecutive dl elements diff --git a/test/ParsedownExtraTest.php b/test/ParsedownExtraTest.php index 4fff778..45f2292 100644 --- a/test/ParsedownExtraTest.php +++ b/test/ParsedownExtraTest.php @@ -17,4 +17,22 @@ protected function initParsedown() return $Parsedown; } + + public function testMultipleFootnoteCalls() + { + $parsedown = $this->initParsedown(); + + $markdown = file_get_contents(__DIR__.'/data/footnote.md'); + + $expectedMarkup = file_get_contents(__DIR__.'/data/footnote.html'); + + $expectedMarkup = str_replace("\r\n", "\n", $expectedMarkup); + $expectedMarkup = str_replace("\r", "\n", $expectedMarkup); + + $actualMarkup = $parsedown->text($markdown); + $this->assertEquals($expectedMarkup, $actualMarkup); + + $actualMarkup = $parsedown->text($markdown); + $this->assertEquals($expectedMarkup, $actualMarkup); + } }