You are here

public static function Markdown::defaultTransform in Markdown 7

* Simple function interface - Initialize the parser and return the result * of its transform method. This will work fine for derived classes too. * * @api * *

Parameters

string $text: * @return string

Overrides MarkdownInterface::defaultTransform

File

includes/Markdown.php, line 32

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

public static function defaultTransform($text) {

  // Take parser class on which this function was called.
  $parser_class = \get_called_class();

  // Try to take parser from the static parser list
  static $parser_list;
  $parser =& $parser_list[$parser_class];

  // Create the parser it not already set
  if (!$parser) {
    $parser = new $parser_class();
  }

  // Transform text using parser.
  return $parser
    ->transform($text);
}