MarkdownBase.php 890 Bytes
Newer Older
1 2 3 4 5 6 7
<?php
/**
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @link http://www.yiiframework.com/
 * @license http://www.yiiframework.com/license/
 */

8
namespace yii\helpers;
9 10 11 12

use Michelf\MarkdownExtra;

/**
13
 * MarkdownBase provides concrete implementation for [[Markdown]].
14
 *
15
 * Do not use MarkdownBase. Use [[Markdown]] instead.
16 17 18 19
 *
 * @author Alexander Makarov <sam@rmcreative.ru>
 * @since 2.0
 */
20
class MarkdownBase
21 22 23 24 25 26
{
	/**
	 * @var MarkdownExtra
	 */
	protected static $markdown;

Alexander Makarov committed
27 28 29 30 31 32 33
	/**
	 * Converts markdown into HTML
	 *
	 * @param string $content
	 * @param array $config
	 * @return string
	 */
34 35
	public static function process($content, $config = array())
	{
resurtm committed
36
		if (static::$markdown === null) {
37 38 39 40 41 42 43 44
			static::$markdown = new MarkdownExtra();
		}
		foreach ($config as $name => $value) {
			static::$markdown->{$name} = $value;
		}
		return static::$markdown->transform($content);
	}
}