mirror of
https://github.com/typecho/typecho.git
synced 2025-04-25 12:12:22 +02:00
fix #623
This commit is contained in:
parent
9e1b61e0f0
commit
b3dbef1377
@ -444,18 +444,37 @@
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (this.html) {
|
||||
if (!!(matches = line.match(/^(\s*)\$\$(\s*)$/))) {
|
||||
if (this.isBlock('math')) {
|
||||
this.setBlock(key).endBlock();
|
||||
} else {
|
||||
this.startBlock('math', key);
|
||||
}
|
||||
continue;
|
||||
} else if (this.isBlock('math')) {
|
||||
this.setBlock(key);
|
||||
continue;
|
||||
if (!!(matches = line.match(/^(\s*)\$\$(\s*)$/))) {
|
||||
if (this.isBlock('math')) {
|
||||
this.setBlock(key).endBlock();
|
||||
} else {
|
||||
this.startBlock('math', key);
|
||||
}
|
||||
continue;
|
||||
} else if (this.isBlock('math')) {
|
||||
this.setBlock(key);
|
||||
continue;
|
||||
}
|
||||
if (!!(line.match(/^ {4}/))) {
|
||||
emptyCount = 0;
|
||||
if ((this.isBlock('pre')) || this.isBlock('list')) {
|
||||
this.setBlock(key);
|
||||
} else {
|
||||
this.startBlock('pre', key);
|
||||
}
|
||||
continue;
|
||||
} else if (this.isBlock('pre')) {
|
||||
if (line.match(/^\s*$/)) {
|
||||
if (emptyCount > 0) {
|
||||
this.startBlock('normal', key);
|
||||
} else {
|
||||
this.setBlock(key);
|
||||
}
|
||||
emptyCount += 1;
|
||||
} else {
|
||||
this.startBlock('normal', key);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!!(matches = line.match(new RegExp("^\\s*<(" + special + ")(\\s+[^>]*)?>", 'i')))) {
|
||||
tag = matches[1].toLowerCase();
|
||||
@ -474,14 +493,6 @@
|
||||
continue;
|
||||
}
|
||||
switch (true) {
|
||||
case !!(line.match(/^ {4}/)):
|
||||
emptyCount = 0;
|
||||
if ((this.isBlock('pre')) || this.isBlock('list')) {
|
||||
this.setBlock(key);
|
||||
} else {
|
||||
this.startBlock('pre', key);
|
||||
}
|
||||
break;
|
||||
case !!(matches = line.match(/^(\s*)((?:[0-9a-z]+\.)|\-|\+|\*)\s+/)):
|
||||
space = matches[1].length;
|
||||
emptyCount = 0;
|
||||
@ -506,7 +517,7 @@
|
||||
this.startBlock('quote', key);
|
||||
}
|
||||
break;
|
||||
case !!(matches = line.match(/^((?:(?:(?:[ :]*\-[ :]*)+(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-[ :]*)+)|(?:(?:[ :]*\-[ :]*)+(?:\||\+)(?:[ :]*\-[ :]*)+))+)$/)):
|
||||
case !!(matches = line.match(/^((?:(?:(?:[ :]*\-[ :]*)+(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-[ :]*)+(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-[ :]*)+))+)$/)):
|
||||
if (this.isBlock('table')) {
|
||||
block[3][0].push(block[3][2]);
|
||||
block[3][2] += 1;
|
||||
@ -586,17 +597,6 @@
|
||||
} else {
|
||||
this.startBlock('normal', key);
|
||||
}
|
||||
} else if (this.isBlock('pre')) {
|
||||
if (line.match(/^\s*$/)) {
|
||||
if (emptyCount > 0) {
|
||||
this.startBlock('normal', key);
|
||||
} else {
|
||||
this.setBlock(key);
|
||||
}
|
||||
emptyCount += 1;
|
||||
} else {
|
||||
this.startBlock('normal', key);
|
||||
}
|
||||
} else if (this.isBlock('quote')) {
|
||||
if (line.match(/^(\s*)/)) {
|
||||
if (emptyCount > 0) {
|
||||
|
@ -595,6 +595,33 @@ class HyperDown
|
||||
continue;
|
||||
}
|
||||
|
||||
// pre block
|
||||
if (preg_match("/^ {4}/", $line)) {
|
||||
$emptyCount = 0;
|
||||
|
||||
if ($this->isBlock('pre') || $this->isBlock('list')) {
|
||||
$this->setBlock($key);
|
||||
} else if ($this->isBlock('normal')) {
|
||||
$this->startBlock('pre', $key);
|
||||
}
|
||||
|
||||
continue;
|
||||
} else if ($this->isBlock('pre')) {
|
||||
if (preg_match("/^\s*$/", $line)) {
|
||||
if ($emptyCount > 0) {
|
||||
$this->startBlock('normal', $key);
|
||||
} else {
|
||||
$this->setBlock($key);
|
||||
}
|
||||
|
||||
$emptyCount ++;
|
||||
} else {
|
||||
$this->startBlock('normal', $key);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// html block is special too
|
||||
if (preg_match("/^\s*<({$special})(\s+[^>]*)?>/i", $line, $matches)) {
|
||||
$tag = strtolower($matches[1]);
|
||||
@ -618,17 +645,6 @@ class HyperDown
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
// pre block
|
||||
case preg_match("/^ {4}/", $line):
|
||||
$emptyCount = 0;
|
||||
|
||||
if ($this->isBlock('pre') || $this->isBlock('list')) {
|
||||
$this->setBlock($key);
|
||||
} else if ($this->isBlock('normal')) {
|
||||
$this->startBlock('pre', $key);
|
||||
}
|
||||
break;
|
||||
|
||||
// list
|
||||
case preg_match("/^(\s*)((?:[0-9a-z]+\.)|\-|\+|\*)\s+/", $line, $matches):
|
||||
$space = strlen($matches[1]);
|
||||
@ -667,7 +683,7 @@ class HyperDown
|
||||
break;
|
||||
|
||||
// table
|
||||
case preg_match("/^((?:(?:(?:[ :]*\-[ :]*)+(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-[ :]*)+)|(?:(?:[ :]*\-[ :]*)+(?:\||\+)(?:[ :]*\-[ :]*)+))+)$/", $line, $matches):
|
||||
case preg_match("/^((?:(?:(?:[ :]*\-[ :]*)+(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-[ :]*)+(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-[ :]*)+))+)$/", $line, $matches):
|
||||
if ($this->isBlock('table')) {
|
||||
$block[3][0][] = $block[3][2];
|
||||
$block[3][2] ++;
|
||||
@ -769,18 +785,6 @@ class HyperDown
|
||||
} else {
|
||||
$this->startBlock('normal', $key);
|
||||
}
|
||||
} else if ($this->isBlock('pre')) {
|
||||
if (preg_match("/^\s*$/", $line)) {
|
||||
if ($emptyCount > 0) {
|
||||
$this->startBlock('normal', $key);
|
||||
} else {
|
||||
$this->setBlock($key);
|
||||
}
|
||||
|
||||
$emptyCount ++;
|
||||
} else {
|
||||
$this->startBlock('normal', $key);
|
||||
}
|
||||
} else if ($this->isBlock('quote')) {
|
||||
if (preg_match("/^(\s*)/", $line)) { // empty line
|
||||
if ($emptyCount > 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user