This commit is contained in:
joyqi 2019-10-31 16:47:33 +08:00
parent c17bdaf606
commit 75237e6a44
3 changed files with 66 additions and 29 deletions

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.12.2
// Generated by CoffeeScript 1.12.7
(function() {
var Parser,
slice = [].slice;
@ -102,7 +102,7 @@
this.hooks = {};
this.html = false;
this.line = false;
this.blockParsers = [['code', 10], ['shtml', 20], ['pre', 30], ['ahtml', 40], ['list', 50], ['math', 60], ['html', 70], ['footnote', 80], ['definition', 90], ['quote', 100], ['table', 110], ['sh', 120], ['mh', 130], ['hr', 140], ['default', 9999]];
this.blockParsers = [['code', 10], ['shtml', 20], ['pre', 30], ['ahtml', 40], ['shr', 50], ['list', 60], ['math', 70], ['html', 80], ['footnote', 90], ['definition', 100], ['quote', 110], ['table', 120], ['sh', 130], ['mh', 140], ['dhr', 150], ['default', 9999]];
this.parsers = {};
}
@ -781,8 +781,16 @@
return true;
};
Parser.prototype.parseBlockHr = function(block, key, line) {
if (!!(line.match(/^[-\*]{3,}\s*$/))) {
Parser.prototype.parseBlockShr = function(block, key, line) {
if (!!(line.match(/^(\* *){3,}\s*$/))) {
this.startBlock('hr', key).endBlock();
return false;
}
return true;
};
Parser.prototype.parseBlockDhr = function(block, key, line) {
if (!!(line.match(/^(- *){3,}\s*$/))) {
this.startBlock('hr', key).endBlock();
return false;
}

View File

@ -58,16 +58,17 @@ class HyperDown
array('shtml', 20),
array('pre', 30),
array('ahtml', 40),
array('list', 50),
array('math', 60),
array('html', 70),
array('footnote', 80),
array('definition', 90),
array('quote', 100),
array('table', 110),
array('sh', 120),
array('mh', 130),
array('hr', 140),
array('shr', 50),
array('list', 60),
array('math', 70),
array('html', 80),
array('footnote', 90),
array('definition', 100),
array('quote', 110),
array('table', 120),
array('sh', 130),
array('mh', 140),
array('dhr', 150),
array('default', 9999)
);
@ -264,7 +265,7 @@ class HyperDown
$result = $this->call('after' . ucfirst($method), $result, $value);
$html .= $result;
}
}
return $html;
}
@ -377,15 +378,15 @@ class HyperDown
public function parseInline($text, $whiteList = '', $clearHolders = true, $enableAutoLink = true)
{
$self = $this;
$text = $this->call('beforeParseInline', $text);
$text = $this->call('beforeParseInline', $text);
// code
$text = preg_replace_callback(
"/(^|[^\\\])(`+)(.+?)\\2/",
function ($matches) use ($self) {
return $matches[1] . $self->makeHolder(
'<code>' . htmlspecialchars($matches[3]) . '</code>'
);
'<code>' . htmlspecialchars($matches[3]) . '</code>'
);
},
$text
);
@ -395,8 +396,8 @@ class HyperDown
"/(^|[^\\\])(\\$+)(.+?)\\2/",
function ($matches) use ($self) {
return $matches[1] . $self->makeHolder(
$matches[2] . htmlspecialchars($matches[3]) . $matches[2]
);
$matches[2] . htmlspecialchars($matches[3]) . $matches[2]
);
},
$text
);
@ -431,8 +432,8 @@ class HyperDown
"/<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/i",
function ($matches) use ($self, $whiteList) {
if ($self->_html || false !== stripos(
'|' . $self->_commonWhiteList . '|' . $whiteList . '|', '|' . $matches[2] . '|'
)) {
'|' . $self->_commonWhiteList . '|' . $whiteList . '|', '|' . $matches[2] . '|'
)) {
return $self->makeHolder($matches[0]);
} else {
return htmlspecialchars($matches[0]);
@ -522,7 +523,7 @@ class HyperDown
return $self->makeHolder($result);
},
$text
);
);
// strong and em and some fuck
$text = $this->parseInlineCallback($text);
@ -1067,7 +1068,7 @@ class HyperDown
private function parseBlockMh($block, $key, $line, &$state, $lines)
{
if (preg_match("/^\s*((=|-){2,})\s*$/", $line, $matches)
&& ($block && $block[0] == "normal" && !preg_match("/^\s*$/", $lines[$block[2]]))) { // check if last line isn't empty
&& ($block && $block[0] == "normal" && !preg_match("/^\s*$/", $lines[$block[2]]))) { // check if last line isn't empty
if ($this->isBlock('normal')) {
$this->backBlock(1, 'mh', $matches[1][0] == '=' ? 1 : 2)
->setBlock($key)
@ -1088,9 +1089,27 @@ class HyperDown
* @param $line
* @return bool
*/
private function parseBlockHr($block, $key, $line)
private function parseBlockShr($block, $key, $line)
{
if (preg_match("/^[-\*]{3,}\s*$/", $line)) {
if (preg_match("/^(\* *){3,}\s*$/", $line)) {
$this->startBlock('hr', $key)
->endBlock();
return false;
}
return true;
}
/**
* @param $block
* @param $key
* @param $line
* @return bool
*/
private function parseBlockDhr($block, $key, $line)
{
if (preg_match("/^(- *){3,}\s*$/", $line)) {
$this->startBlock('hr', $key)
->endBlock();
@ -1384,7 +1403,7 @@ class HyperDown
if (preg_match("/^(\s*)/", $line, $matches)) {
$space = strlen($matches[1]);
if ($space > 0) {
$secondMinSpace = min($space, $secondMinSpace);
$secondFound = true;

View File

@ -638,13 +638,23 @@ class Widget_Abstract_Contents extends Widget_Abstract
->select()->from('table.metas')
->join('table.relationships', 'table.relationships.mid = table.metas.mid')
->where('table.relationships.cid = ?', $value['cid'])
->where('table.metas.type = ?', 'category')
->order('table.metas.order', Typecho_Db::SORT_ASC), array($this->widget('Widget_Metas_Category_List'), 'filter'));
->where('table.metas.type = ?', 'category'), array($this->widget('Widget_Metas_Category_List'), 'filter'));
$value['category'] = NULL;
$value['directory'] = array();
/** 取出第一个分类作为slug条件 */
if (!empty($value['categories'])) {
/** 使用自定义排序 */
usort($value['categories'], function ($a, $b) {
$field = 'order';
if ($a['order'] == $b['order']) {
$field = 'mid';
}
return $a[$field] < $b[$field] ? -1 : 1;
});
$value['category'] = $value['categories'][0]['slug'];
$value['directory'] = $this->widget('Widget_Metas_Category_List')->getAllParentsSlug($value['categories'][0]['mid']);