2011-02-03, 01:31 AM
After much searching, I still cannot find a solution to my dilemma. I'd like to parse all links within code tags; for what I am doing, I'd like to use code tags instead of quote tags.
Here is the effect I'm trying to achieve:
Here is the code from class_parser.php:
I'd really appreciate the help.
Here is the effect I'm trying to achieve:
Here is the code from class_parser.php:
* Parses code MyCode.
*
* @param string The message to be parsed
* @param boolean Are we formatting as text?
* @return string The parsed message.
*/
function mycode_parse_code($code, $text_only=false)
{
global $lang;
if($text_only == true)
{
return "\n{$lang->code}\n--\n{$code}\n--\n";
}
// Clean the string before parsing.
$code = preg_replace('#^(\t*)(\n|\r|\0|\x0B| )*#', '\\1', $code);
$code = rtrim($code);
$original = preg_replace('#^\t*#', '', $code);
if(empty($original))
{
return;
}
$code = str_replace('$', '$', $code);
$code = preg_replace('#\$([0-9])#', '\\\$\\1', $code);
$code = str_replace('\\', '\', $code);
$code = str_replace("\t", ' ', $code);
$code = str_replace(" ", ' ', $code);
$lcurl = 'http://wgtools.com/link-checker/?url=' . urlencode($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
$wglc = ' [<a href="' . $lcurl .'" target="_blank"><strong>Check Links</strong></a>]';
return "<div class=\"codeblock\">\n<div class=\"title\">".$lang->code.$wglc."\n</div><div class=\"body\" dir=\"ltr\"><code>".$code."</code></div></div>\n";
}
/**
I'd really appreciate the help.