You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
12 years ago
|
<?php
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||
|
* @link http://www.yiiframework.com/
|
||
|
* @license http://www.yiiframework.com/license/
|
||
|
*/
|
||
|
|
||
|
namespace yii\helpers\base;
|
||
|
|
||
|
use Michelf\MarkdownExtra;
|
||
|
|
||
|
/**
|
||
|
* Markdown provides an ability to transform markdown into HTML.
|
||
|
*
|
||
|
* Basic usage is the following:
|
||
|
*
|
||
|
* ```php
|
||
12 years ago
|
* $myHtml = Markdown::process($myText);
|
||
12 years ago
|
* ```
|
||
|
*
|
||
|
* If you want to configure the parser:
|
||
|
*
|
||
|
* ```php
|
||
12 years ago
|
* $myHtml = Markdown::process($myText, array(
|
||
12 years ago
|
* 'fn_id_prefix' => 'footnote_',
|
||
|
* ));
|
||
|
* ```
|
||
|
*
|
||
|
* For more details please refer to [PHP Markdown library documentation](http://michelf.ca/projects/php-markdown/).
|
||
|
* @author Alexander Makarov <sam@rmcreative.ru>
|
||
|
* @since 2.0
|
||
|
*/
|
||
|
class Markdown
|
||
|
{
|
||
|
/**
|
||
|
* @var MarkdownExtra
|
||
|
*/
|
||
|
protected static $markdown;
|
||
|
|
||
|
public static function process($content, $config = array())
|
||
|
{
|
||
12 years ago
|
if (static::$markdown === null) {
|
||
12 years ago
|
static::$markdown = new MarkdownExtra();
|
||
|
}
|
||
|
foreach ($config as $name => $value) {
|
||
|
static::$markdown->{$name} = $value;
|
||
|
}
|
||
|
return static::$markdown->transform($content);
|
||
|
}
|
||
|
}
|