Skip to content

Commit

Permalink
Remove END_TOC marker search against closing </ul> tag
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Mar 22, 2023
1 parent 61309e1 commit f00e27a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public function execute(): string
$environment->addExtension(new TableOfContentsExtension());

$converter = new MarkdownConverter($environment);
$html = $converter->convert("[[END_TOC]]\n".$this->markdown)->getContent();
$html = $converter->convert($this->markdown)->getContent();

// Return everything before the [[END_TOC]] marker.
return substr($html, 0, strpos($html, '<p>[[END_TOC]]'));
// Return everything before the closing </ul> tag
return substr($html, 0, strpos($html, '</ul>') + 5);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testCanGenerateTableOfContents()
$this->assertIsString($result);
$this->assertStringContainsString('<ul>', $result);
$this->assertStringContainsString('<a href="#level-2">Level 2</a>', $result);
$this->assertStringNotContainsString('[[END_TOC]]', $result);
$this->assertStringContainsString('</ul>', $result);
}

public function testReturnStringContainsExpectedContent()
Expand Down

0 comments on commit f00e27a

Please sign in to comment.