/** * @brief Parse the human data and return html * * @param string $data The data to parse * @return string The parsed data */ public function parse($content) { $ret = new StringParser($content); $ret->replace(array('/\\r\\n?/' => '\\n', '/&/' => '&', '/</' => '<', '/>/' => '>')); $ret->replace('/\\n?<blockquote>\\n*(.+?)\\n*<\\/blockquote>/', '<blockquote>$1</blockquote>'); $ret->replaceEach(array('b', 'i', 'em', 'strong', 'u'), '/<($ITEM$)>(.+?)<\\/($ITEM$)>/', '<$1>$2</$1>'); $ret->replace('/<a.+?href\\s*=\\s*[\'"](.+?)["\'].*?>(.+?)<\\/a>/', '<a href="$1">$2</a>'); $ret->replace('/\\n\\n+/', "</p>\n\n<p>"); $ret->replace('/([^\\n]\\n)(?=[^\\n])/', '\\1<br />'); return "<p>" . $ret->get() . "</p>"; }