Fix call to deprecated "convertToHtml" method

This commit is contained in:
Jérémy Derussé
2022-01-29 15:06:54 +01:00
committed by Fabien Potencier
parent bbc33772da
commit 779fdd09b4
+7 -1
View File
@@ -16,14 +16,20 @@ use League\CommonMark\CommonMarkConverter;
class LeagueMarkdown implements MarkdownInterface class LeagueMarkdown implements MarkdownInterface
{ {
private $converter; private $converter;
private $legacySupport;
public function __construct(CommonMarkConverter $converter = null) public function __construct(CommonMarkConverter $converter = null)
{ {
$this->converter = $converter ?: new CommonMarkConverter(); $this->converter = $converter ?: new CommonMarkConverter();
$this->legacySupport = !method_exists($this->converter, 'convert');
} }
public function convert(string $body): string public function convert(string $body): string
{ {
return $this->converter->convertToHtml($body); if ($this->legacySupport) {
return $this->converter->convertToHtml($body);
}
return $this->converter->convert($body);
} }
} }