Owl\Libraries\CustomMarkdown::exParseLinkOrImage PHP Method

exParseLinkOrImage() protected method

@Override
protected exParseLinkOrImage ( $markdown )
    protected function exParseLinkOrImage($markdown)
    {
        if (strpos($markdown, ']') !== false && preg_match('/\\[((?:[^][]|(?R))*)\\]/', $markdown, $textMatches)) {
            // TODO improve bracket regex
            $text = $textMatches[1];
            $offset = strlen($textMatches[0]);
            $markdown = substr($markdown, $offset);
            if (preg_match('/^\\(([^\\s]*?)(\\s+"(.*?)")?(\\s+=([0-9]+)?x([0-9]+)?)?\\)/', $markdown, $refMatches)) {
                // inline link
                return [$text, $refMatches[1], empty($refMatches[3]) ? null : $refMatches[3], $offset + strlen($refMatches[0]), isset($refMatches[5]) ? $refMatches[5] : null, isset($refMatches[6]) ? $refMatches[6] : null];
            } elseif (preg_match('/^[ \\n]?\\[(.*?)\\]/', $markdown, $refMatches)) {
                // reference style link
                if (empty($refMatches[1])) {
                    $key = strtolower($text);
                } else {
                    $key = strtolower($refMatches[1]);
                }
                if (isset($this->references[$key])) {
                    return [$text, $this->references[$key]['url'], empty($this->references[$key]['title']) ? null : $this->references[$key]['title'], $offset + strlen($refMatches[0])];
                }
            }
        }
        return false;
    }