public static function PeclCmark::version in Markdown 3.0.x
Retrieves the version of the installed parser.
Return value
string|null
Overrides BaseParser::version
File
- src/Plugin/ Markdown/ PeclCmark.php, line 29 
Class
- PeclCmark
- Plugin annotation @MarkdownParser( id = "pecl/cmark", label = @Translation("PECL cmark/libcmark"), url = "https://pecl.php.net/package/cmark", )
Namespace
Drupal\markdown\Plugin\MarkdownCode
public static function version() : string {
  if (static::installed()) {
    // Retrieve the PECL extension version.
    $version = [
      phpversion('cmark'),
    ];
    // Extract the actual cmark library version being used.
    // @todo Revisit this to see if there's a better way.
    ob_start();
    phpinfo(INFO_MODULES);
    $php_info = ob_get_contents();
    ob_clean();
    preg_match('/libcmark library.*(\\d+\\.\\d+\\.\\d+)/', $php_info, $matches);
    if (!empty($matches[1])) {
      $version[] = $matches[1];
    }
    return implode('/', $version);
  }
}