mirror of
https://github.com/typecho/typecho.git
synced 2025-03-19 01:19:40 +01:00
fix more split
This commit is contained in:
parent
2903f6a191
commit
394b93bbd2
@ -9,7 +9,12 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||
* @license GNU General Public License 2.0
|
||||
*/
|
||||
class Markdown
|
||||
{
|
||||
{
|
||||
/**
|
||||
* @var HyperDown
|
||||
*/
|
||||
public static $parser;
|
||||
|
||||
/**
|
||||
* convert
|
||||
*
|
||||
@ -18,14 +23,13 @@ class Markdown
|
||||
*/
|
||||
public static function convert($text)
|
||||
{
|
||||
static $parser;
|
||||
|
||||
if (empty($parser)) {
|
||||
$parser = new HyperDown();
|
||||
$parser->hook('afterParseCode', array('Markdown', 'transerCodeClass'));
|
||||
if (empty(self::$parser)) {
|
||||
self::$parser = new HyperDown();
|
||||
self::$parser->hook('afterParseCode', array('Markdown', 'transerCodeClass'));
|
||||
self::$parser->hook('beforeParseInline', array('Markdown', 'transerComment'));
|
||||
}
|
||||
|
||||
return $parser->makeHtml($text);
|
||||
return self::$parser->makeHtml($text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,5 +42,23 @@ class Markdown
|
||||
{
|
||||
return preg_replace("/<code class=\"([_a-z0-9-]+)\">/i", "<code class=\"lang-\\1\">", $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $html
|
||||
* @return mixed
|
||||
*/
|
||||
public static function transerComment($html)
|
||||
{
|
||||
return preg_replace_callback("/<!\-\-(.+?)\-\->/s", array('Markdown', 'transerCommentCallback'), $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $matches
|
||||
* @return string
|
||||
*/
|
||||
public static function transerCommentCallback($matches)
|
||||
{
|
||||
return self::$parser->makeHolder($matches[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user