function block($text)
{
$pre = $php = $txp = $notextile = false;
$find = array('bq', 'h[1-6]', 'fn\d+', 'p');
$text = preg_replace("/(.+)\n(?![#*\s|])/",
"$1
", $text);
$text = explode("\n", $text);
array_push($text, " ");
foreach($text as $line) {
if (preg_match('/
/i', $line)) {
$pre = true;
}
if (preg_match('//i', $line)) {
$notextile = true;
}
elseif (preg_match('//i', $line)) {
$php = true;
}
elseif (preg_match('/^\s*a$this->c)\.(?::(\S+))? (.*)$/",
array(&$this, "fBlock"), $line)
: $line;
}
$line = (!$php and !$txp and !$notextile) ? preg_replace('/^(?!\t|<\/?pre|<\/?code|$| )(.*)/', "\t$1
", $line) : $line;
$line = ($pre or $php or $notextile) ? str_replace("
", "\n", $line):$line;
if (preg_match('/<\/pre>/i', $line)) {
$pre = false;
}
if (preg_match('/<\/notextile>/i', $line)) {
$notextile = false;
}
elseif (preg_match('/<\/txp:php>/i', $line)) {
$php = false;
}
if ($txp == true) $txp = false;
$out[] = $line;
}
return join("\n", $out);
}