更换为MarkdownExtraExtended解析引擎

This commit is contained in:
祁宁
2014-10-11 16:25:56 +08:00
parent 25f5e34e66
commit 04b1ef83d2
5 changed files with 6272 additions and 17 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
<?php if(!defined('__TYPECHO_ADMIN__')) exit; ?>
<?php $content = !empty($post) ? $post : $page; if ($options->markdown): ?>
<script src="<?php $options->adminStaticUrl('js', 'pagedown.js?v=' . $suffixVersion); ?>"></script>
<script src="<?php $options->adminStaticUrl('js', 'stmd.js?v=' . $suffixVersion); ?>"></script>
<script src="<?php $options->adminStaticUrl('js', 'markdown-extra-extended.js?v=' . $suffixVersion); ?>"></script>
<script src="<?php $options->adminStaticUrl('js', 'diff.js?v=' . $suffixVersion); ?>"></script>
<script>
$(document).ready(function () {
File diff suppressed because it is too large Load Diff
+4 -6
View File
@@ -171,26 +171,24 @@
(function () {
Typecho.Markdown = function () {
/*
this.writer = new stmd.HtmlRenderer();
this.reader = new stmd.DocParser();
/* begin hardbreak hack */
var w = this.writer, r = w.renderInline;
w.renderInline = function (inline) {
if (inline.t == 'Softbreak') inline.t = 'Hardbreak';
return r.call(w, inline);
};
/* end hardbreak hack */
*/
this.hooks = new Markdown.HookCollection()
this.hooks = new Markdown.HookCollection();
this.hooks.addNoop('postConversion');
};
Typecho.Markdown.prototype.makeHtml = function (text) {
var doc = this.reader.parse(text),
html = this.writer.renderBlock(doc);
html = MarkdownText(text);
return this.hooks.postConversion(html);
};
+4 -10
View File
@@ -44,19 +44,13 @@ class Markdown
*/
public static function convert($text)
{
static $docParser, $renderer;
static $parser;
if (empty($docParser)) {
$docParser = new CommonMark_DocParser();
if (empty($parser)) {
$parser = new MarkdownExtraExtended();
}
if (empty($renderer)) {
$renderer = new HtmlRendererExtra();
}
$doc = $docParser->parse($text);
return $renderer->render($doc);
return $parser->transform($text);
}
}
File diff suppressed because it is too large Load Diff