Skip to content

Commit

Permalink
bug #3638 Fix call to deprecated "convertToHtml" method (jderusse)
Browse files Browse the repository at this point in the history
This PR was submitted for the 3.x branch but it was merged into the 2.x branch instead.

Discussion
----------

Fix call to deprecated "convertToHtml" method

note: We can not rely on the new interface `ConverterInterface` because this interface already existed in [version 1.0](https://github.com/thephpleague/commonmark/blob/1.0/src/ConverterInterface.php)

Commits
-------

779fdd0 Fix call to deprecated "convertToHtml" method
  • Loading branch information
fabpot committed Jan 29, 2022
2 parents bbc3377 + 779fdd0 commit e056e63
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion extra/markdown-extra/LeagueMarkdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@
class LeagueMarkdown implements MarkdownInterface
{
private $converter;
private $legacySupport;

public function __construct(CommonMarkConverter $converter = null)
{
$this->converter = $converter ?: new CommonMarkConverter();
$this->legacySupport = !method_exists($this->converter, 'convert');
}

public function convert(string $body): string
{
return $this->converter->convertToHtml($body);
if ($this->legacySupport) {
return $this->converter->convertToHtml($body);
}

return $this->converter->convert($body);
}
}

0 comments on commit e056e63

Please sign in to comment.