reset(); $in_code_block = 0; $num = 0; foreach (preg_split("!\r?\n!", $text) as $line) { if ($num++) $this->out .= ' '; $result = ''; if ($this->in_code_block || trim($line) == MTrack_Wiki_Parser::STARTBLOCK) { $in_code_block++; } elseif (trim($line) == MTrack_Wiki_Parser::ENDBLOCK) { if ($in_code_block) { $in_code_block--; if ($in_code_block == 0) { $result .= " [...]\n"; } } } elseif (!$in_code_block) { $result .= "$line\n"; } $result = $this->_apply_rules(rtrim($result, "\r\n")); $this->out .= $result; $this->close_tag(null); } } }