ref #580
This commit is contained in:
joyqi
2017-11-04 12:12:30 +08:00
parent fee8bcc63c
commit 36742a6fdb
2 changed files with 65 additions and 3 deletions
+37 -1
View File
@@ -527,6 +527,7 @@ class HyperDown
$this->_pos = -1;
$special = implode("|", array_keys($this->_specialWhiteList));
$emptyCount = 0;
$autoHtml = false;
// analyze by line
foreach ($lines as $key => $line) {
@@ -567,7 +568,7 @@ class HyperDown
// super html mode
if ($this->_html) {
if (preg_match("/^(\s*)!!!(\s*)$/", $line, $matches)) {
if (!$autoHtml && preg_match("/^(\s*)!!!(\s*)$/", $line, $matches)) {
if ($this->isBlock('shtml')) {
$this->setBlock($key)->endBlock();
} else {
@@ -579,6 +580,30 @@ class HyperDown
$this->setBlock($key);
continue;
}
// auto html
if (preg_match("/^\s*<([a-z0-9-]+)(\s+[^>]*)?>/i", $line, $matches)) {
if ($this->isBlock('ahtml')) {
$this->setBlock($key);
continue;
} else if ((empty($matches[2]) || $matches[2] != '/') && !preg_match("/^(area|base|br|col|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i", $matches[1])) {
$this->startBlock('ahtml', $key);
if (strpos($line, "</{$matches[1]}>") !== false) {
$this->endBlock();
} else {
$autoHtml = $matches[1];
}
continue;
}
} else if (!!$autoHtml && strpos($line, "</{$autoHtml}>") !== false) {
$this->setBlock($key)->endBlock();
$autoHtml = false;
continue;
} else if ($this->isBlock('ahtml')) {
$this->setBlock($key);
continue;
}
}
// mathjax mode
@@ -920,6 +945,17 @@ class HyperDown
return preg_match("/^\s*$/", $str) ? '' : '<pre><code>' . $str . '</code></pre>';
}
/**
* parseAhtml
*
* @param array $lines
* @return string
*/
private function parseAhtml(array $lines)
{
return trim(implode("\n", $lines));
}
/**
* parseShtml
*