You are here

public function Description::getFormattedContents in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Description.php \phpDocumentor\Reflection\DocBlock\Description::getFormattedContents()

Return a formatted variant of the Long Description using MarkDown.

@todo this should become a more intelligent piece of code where the configuration contains a setting what format long descriptions are.

@codeCoverageIgnore Will be removed soon, in favor of adapters at PhpDocumentor itself that will process text in various formats.

Return value

string

File

vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Description.php, line 149

Class

Description
Parses a Description of a DocBlock or tag.

Namespace

phpDocumentor\Reflection\DocBlock

Code

public function getFormattedContents() {
  $result = $this->contents;

  // if the long description contains a plain HTML <code> element, surround
  // it with a pre element. Please note that we explicitly used str_replace
  // and not preg_replace to gain performance
  if (strpos($result, '<code>') !== false) {
    $result = str_replace(array(
      '<code>',
      "<code>\r\n",
      "<code>\n",
      "<code>\r",
      '</code>',
    ), array(
      '<pre><code>',
      '<code>',
      '<code>',
      '<code>',
      '</code></pre>',
    ), $result);
  }
  if (class_exists('Parsedown')) {
    $markdown = \Parsedown::instance();
    $result = $markdown
      ->parse($result);
  }
  elseif (class_exists('dflydev\\markdown\\MarkdownExtraParser')) {
    $markdown = new \dflydev\markdown\MarkdownExtraParser();
    $result = $markdown
      ->transformMarkdown($result);
  }
  return trim($result);
}