You are here

public function CommonMark::converter in Markdown 8.2

Retrieves a CommonMark converter instance.

Return value

\League\CommonMark\CommonMarkConverter|\ColinODell\CommonMark\CommonMarkConverter A CommonMark converter.

File

src/Plugin/Markdown/CommonMark/CommonMark.php, line 305

Class

CommonMark
Support for CommonMark by The League of Extraordinary Packages.

Namespace

Drupal\markdown\Plugin\Markdown\CommonMark

Code

public function converter() {
  if (!$this->converter) {
    $version = $this
      ->getVersion();
    if (Semver::satisfies($version, '>=0.13.0')) {
      $this->converter = $this
        ->getObject($this
        ->getSettings(TRUE), $this
        ->getEnvironment());
    }
    elseif (Semver::satisfies($version, '>=0.6.0 <0.13.0')) {
      $this->converter = $this
        ->getObject($this
        ->getSettings(TRUE));
    }
    else {
      $this->converter = $this
        ->getObject();
    }
  }
  return $this->converter;
}