function format($str, $type = '') { $tmp = new format($str, true, true); $tmp->html(array('b', 'i', 'u', 's')); if ($type == 'e' || $type == 'p') { //$tmp->parse('#\[tex\](.*?)\[/tex\]#se', '"[img]http://chart.apis.google.com/chart?cht=tx&chl=".rawurlencode("\\1")."[/img]"'); $tmp->tag('img', '<img src="\\1" alt="" />'); $tmp->attribute('img', '<img src="\\2" alt="\\1" />'); $tmp->tag('url', '<a href="\\1" target="_blank">\\1</a>'); $tmp->attribute('url', '<a href="\\1" target="_blank">\\2</a>'); $tmp->tag('link', '<a href="\\1">\\1</a>'); $tmp->attribute('link', '<a href="\\1">\\2</a>'); $tmp->attribute('acronym', '<acronym title="\\1">\\2</acronym>'); $tmp->tag('center', '<div align="center">\\1</div>'); $tmp->attribute('color', '<font color="\\1">\\2</font> '); } elseif ($type == 'c') { $tmp->parse('#https?://[^.\\s]+\\.[^\\s]+#ix', '<a href="\\0" target="_blank">\\0</a>'); $tmp->parse('#(\\s|\\A)\\#([0-9]+)#', '<a href="#comment-\\2">\\0</a>'); } elseif ($type == 'cf') { $tmp->parse('#https?://[^.\\s]+\\.[^\\s]+#ix', '<a href="\\0" target="_blank">\\0</a>'); } return $tmp->result(); }