From 4d673d0cce56382695ca1784a5a654733bcd5b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rubio?= Date: Sun, 28 May 2017 21:29:57 +0200 Subject: [PATCH] =?UTF-8?q?Bugfix:=20reset=20footnote=20count=20after=20ea?= =?UTF-8?q?ch=20=C2=ABtext=C2=BB=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ParsedownExtra.php | 1 + test/ParsedownExtraTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) 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); + } }