Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URL Parsing in Code Tags
#1
I'm currently in a predicament in which a client INSISTS on using code tags for links. He wants clickable links within the tags themselef, so I'm looking for some advice regarding the code already existing within the class_parser file. I believe it's just a simple change in the preg_replace:

This is an example:
Code:
[url]youtube.com[/url]

Here is the full code:

Code:
* 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";
    }

    /**

Here is the wanted outcome (copied from another forum):
[Image: mwsnap259.png]





Users browsing this thread: 1 Guest(s)