Skip to content

Commit 3086223

Browse files
committed
Add test to verify ToC resets between different markdown parses
1 parent a74f9ff commit 3086223

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/TocTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,25 @@ public function testTocMultipleSettings()
216216
$actual = $this->parsedownExtended->text($markdown);
217217
$this->assertEquals($expected, $actual);
218218
}
219+
220+
/**
221+
* Test case to ensure that the ToC resets between different markdown parses.
222+
*/
223+
public function testTocResetsBetweenParses()
224+
{
225+
$this->parsedownExtended->config()->set('headings.auto_anchors', true);
226+
$this->parsedownExtended->config()->set('toc', true);
227+
$this->parsedownExtended->config()->set('toc.tag', '[toc]');
228+
229+
$markdown1 = "[toc]\n# First";
230+
$markdown2 = "[toc]\n# Second";
231+
232+
$this->parsedownExtended->text($markdown1);
233+
$firstToc = $this->parsedownExtended->contentsList();
234+
235+
$this->parsedownExtended->text($markdown2);
236+
$secondToc = $this->parsedownExtended->contentsList();
237+
238+
$this->assertStringNotContainsString('First', $secondToc);
239+
$this->assertStringContainsString('Second', $secondToc);
219240
}

0 commit comments

Comments
 (0)