Skip to content

Commit

Permalink
Allow more than two of the same ID for TOC #209
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Jun 5, 2020
1 parent 6ebdc15 commit d556536
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ protected function getUniqueId(Document $document, $proposed)
++$extension;
} while (in_array("$proposed-$extension", $document->heading_ids));

$document->heading_ids[] = "$proposed-$extension";

return "$proposed-$extension";
}

Expand Down
6 changes: 5 additions & 1 deletion tests/Format/HTML/TableOfContentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testDuplicatedTOC()
{
$converter = new CommonMarkConverter($this->getConfig());

$source = "[TOC]\n# Test\n# Test";
$source = "[TOC]\n# Test\n# Test\n# Test";
$expected = <<<'EXPECTED'
<ul class="TableOfContents">
<li>
Expand All @@ -90,9 +90,13 @@ public function testDuplicatedTOC()
<li>
<p><a href="#page_Test-2">Test</a></p>
</li>
<li>
<p><a href="#page_Test-3">Test</a></p>
</li>
</ul>
<h1 id="page_Test">Test</h1>
<h1 id="page_Test-2">Test</h1>
<h1 id="page_Test-3">Test</h1>

EXPECTED;

Expand Down

0 comments on commit d556536

Please sign in to comment.