Skip to content

Commit ccabe41

Browse files
committed
Add tests for footnotes functionality in ParsedownExtended
1 parent e7c4a86 commit ccabe41

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/FootnotesTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,39 @@ protected function tearDown(): void
1717
{
1818
unset($this->parsedownExtended);
1919
}
20+
21+
public function testFootnotesEnabled()
22+
{
23+
$this->parsedownExtended->config()->set('footnotes', true);
24+
25+
$markdown = "Text with a footnote.[^1]\n\n[^1]: The footnote content.";
26+
$html = $this->parsedownExtended->text($markdown);
27+
28+
$this->assertStringContainsString('<sup', $html);
29+
$this->assertStringContainsString('The footnote content.', $html);
30+
}
31+
32+
public function testFootnotesDisabled()
33+
{
34+
$this->parsedownExtended->config()->set('footnotes', false);
35+
36+
$markdown = "Text with a footnote.[^1]\n\n[^1]: The footnote content.";
37+
$html = $this->parsedownExtended->text($markdown);
38+
39+
// When footnotes are disabled there should be no superscript footnote links
40+
$this->assertStringNotContainsString('<sup', $html);
41+
// The footnote definition is not processed as a footnote, so no back-reference link appears
42+
$this->assertStringNotContainsString('href="#fn:', $html);
43+
}
44+
45+
public function testMultipleFootnotes()
46+
{
47+
$this->parsedownExtended->config()->set('footnotes', true);
48+
49+
$markdown = "First[^1] and second[^2].\n\n[^1]: First footnote.\n\n[^2]: Second footnote.";
50+
$html = $this->parsedownExtended->text($markdown);
51+
52+
$this->assertStringContainsString('First footnote.', $html);
53+
$this->assertStringContainsString('Second footnote.', $html);
54+
}
2055
}

0 commit comments

Comments
 (0)