src/Luminous/Formatters/HtmlFormatter.php
protected function linkifyCb($matches)
    {
        $uri = (isset($matches[1]) && strlen(trim($matches[1]))) ? $matches[0] : "http://" . $matches[0];

        // we dont want to link if it would cause malformed HTML
        $openTags = array();
        $closeTags = array();
        preg_match_all("/<(?!\/)([^\s>]*).*?>/", $matches[0], $openTags, PREG_SET_ORDER);
        preg_match_all("/<\/([^\s>]*).*?>/", $matches[0], $closeTags, PREG_SET_ORDER);

        if (count($openTags) != count($closeTags)) {
            return $matches[0];
        }
        if (isset($openTags[0]) && trim($openTags[0][1]) !== trim($closeTags[0][1])) {
            return $matches[0];
        }

        $uri = strip_tags($uri);

        $target = ($this->strictStandards) ? '' : ' target="_blank"';
        return "<a href='{$uri}' class='link'{$target}>{$matches[0]}</a>";
    }
protected function linkifyCb($matches)
    {
        $uri = (isset($matches[1]) && strlen(trim($matches[1]))) ? $matches[0] : "http://" . $matches[0];

        // we dont want to link if it would cause malformed HTML
        $openTags = array();
        $closeTags = array();
        preg_match_all("/<(?!\/)([^\s>]*).*?>/", $matches[0], $openTags, PREG_SET_ORDER);
        preg_match_all("/<\/([^\s>]*).*?>/", $matches[0], $closeTags, PREG_SET_ORDER);

        if (count($openTags) != count($closeTags)) {
            return $matches[0];
        }
        if (isset($openTags[0]) && trim($openTags[0][1]) !== trim($closeTags[0][1])) {
            return $matches[0];
        }

        $uri = strip_tags($uri);

        $target = ($this->strictStandards) ? '' : ' target="_blank"';
        return "<a href='{$uri}' class='link'{$target}>{$matches[0]}</a>";
    }
protected function linkifyCb ( $ matches ) { $ uri = ( isset ( $ matches [ 1 ] ) && strlen ( trim ( $ matches [ 1 ] ) ) ) ? $ matches [ 0 ] : "http://" . $ matches [ 0 ] ; // we dont want to link if it would cause malformed HTML $ openTags = array ( ) ; $ closeTags = array ( ) ; preg_match_all ( "/<(?!\/)([^\s>]*).*?>/" , $ matches [ 0 ] , $ openTags , PREG_SET_ORDER ) ; preg_match_all ( "/<\/([^\s>]*).*?>/" , $ matches [ 0 ] , $ closeTags , PREG_SET_ORDER ) ; if ( count ( $ openTags ) != count ( $ closeTags ) ) { return $ matches [ 0 ] ; } if ( isset ( $ openTags [ 0 ] ) && trim ( $ openTags [ 0 ] [ 1 ] ) !== trim ( $ closeTags [ 0 ] [ 1 ] ) ) { return $ matches [ 0 ] ; } $ uri = strip_tags ( $ uri ) ; $ target = ( $ this -> strictStandards ) ? '' : ' target="_blank"' ; return "<a href='{$uri}' class='link'{$target}>{$matches[0]}</a>" ; }
Detects and links URLs - callback
Detects and links URLs - callback