Skip to content

Commit e9cd94b

Browse files
committed
Add tests for reference handling in ParsedownExtended
1 parent ccabe41 commit e9cd94b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/ReferencesTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,35 @@ protected function tearDown(): void
1717
{
1818
unset($this->parsedownExtended);
1919
}
20+
21+
public function testReferencesEnabled()
22+
{
23+
$this->parsedownExtended->config()->set('references', true);
24+
25+
$markdown = "[link text][ref]\n\n[ref]: https://example.com";
26+
$html = $this->parsedownExtended->text($markdown);
27+
28+
$this->assertStringContainsString('<a href="https://example.com"', $html);
29+
}
30+
31+
public function testReferencesDisabled()
32+
{
33+
$this->parsedownExtended->config()->set('references', false);
34+
35+
$markdown = "[link text][ref]\n\n[ref]: https://example.com";
36+
$html = $this->parsedownExtended->text($markdown);
37+
38+
$this->assertStringContainsString('[link text][ref]', $html);
39+
}
40+
41+
public function testReferenceWithTitle()
42+
{
43+
$this->parsedownExtended->config()->set('references', true);
44+
45+
$markdown = "[link text][ref]\n\n[ref]: https://example.com \"Example Title\"";
46+
$html = $this->parsedownExtended->text($markdown);
47+
48+
$this->assertStringContainsString('href="https://example.com"', $html);
49+
$this->assertStringContainsString('title="Example Title"', $html);
50+
}
2051
}

0 commit comments

Comments
 (0)