diff --git a/admin/js/hyperdown.js b/admin/js/hyperdown.js index e9b30efc..eb931183 100644 --- a/admin/js/hyperdown.js +++ b/admin/js/hyperdown.js @@ -186,6 +186,9 @@ lines = []; blocks = this.parseBlock(text, lines); html = ''; + if (inline && blocks.length === 1 && blocks[0][0] === 'normal') { + blocks[0][3] = true; + } for (j = 0, len = blocks.length; j < len; j++) { block = blocks[j]; type = block[0], start = block[1], end = block[2], value = block[3]; @@ -1023,8 +1026,11 @@ return '
" + str + "
"; + if (inline) { + return str; + } else { + return "" + str + "
"; + } } }; diff --git a/var/HyperDown.php b/var/HyperDown.php index 5df053eb..c12bb8a8 100644 --- a/var/HyperDown.php +++ b/var/HyperDown.php @@ -234,6 +234,11 @@ class HyperDown $blocks = $this->parseBlock($text, $lines); $html = ''; + // inline mode for single normal block + if ($inline && count($blocks) == 1 && $blocks[0][0] == 'normal') { + $blocks[0][3] = true; + } + foreach ($blocks as $block) { list ($type, $start, $end, $value) = $block; $extract = array_slice($lines, $start, $end - $start + 1); @@ -244,7 +249,7 @@ class HyperDown $result = $this->call('after' . ucfirst($method), $result, $value); $html .= $result; - } + } return $html; } @@ -1443,9 +1448,10 @@ class HyperDown * parseNormal * * @param array $lines + * @param bool $inline * @return string */ - private function parseNormal(array $lines) + private function parseNormal(array $lines, $inline = false) { foreach ($lines as &$line) { $line = $this->parseInline($line); @@ -1455,7 +1461,7 @@ class HyperDown $str = preg_replace("/(\n\s*){2,}/", "", $str);
$str = preg_replace("/\n/", "
", $str);
- return preg_match("/^\s*$/", $str) ? '' : "
{$str}
"; + return preg_match("/^\s*$/", $str) ? '' : ($inline ? $str : "{$str}
"); } /**