You are here

public function ExternalLinkExtension::register in Markdown 8.2

Allows the extension to register itself with the CommonMark Environment.

Parameters

\League\CommonMark\Environment\ConfigurableEnvironmentInterface|\League\CommonMark\ConfigurableEnvironmentInterface|\League\CommonMark\Environment $environment: The CommonMark environment. The exact object passed here has changed namespaces over various versions. It is unlikely to be incompatible, however, explicit typechecking via instanceof may be needed.

Overrides BaseExtension::register

File

src/Plugin/Markdown/CommonMark/Extension/ExternalLinkExtension.php, line 195

Class

ExternalLinkExtension
Plugin annotation @MarkdownAllowedHtml( id = "commonmark-external-links", ) @MarkdownExtension( id = "commonmark-external-links", label = @Translation("External Links"), description = @Translation("Automatically detect links to external sites…

Namespace

Drupal\markdown\Plugin\Markdown\CommonMark\Extension

Code

public function register($environment) {
  parent::register($environment);

  // For older versions of this extension, certain features didn't exist.
  // Add an inline rendered to take care of those features.
  if (Semver::satisfies($this
    ->getParser()
    ->getVersion(), '>=0.19.2 <1.5.0')) {
    $environment
      ->addInlineRenderer('\\League\\CommonMark\\Inline\\Element\\Link', new ExternalLinkRenderer($environment));
  }
}