convert text links to hyperlinks

This commit is contained in:
cornernote 2015-08-12 14:40:38 +09:30
parent 386b8c7946
commit a45c1c618f

View File

@ -447,7 +447,8 @@ class Package extends ActiveRecord
return $parser->parse($this->readme);
}
if ($this->readme_format == 'text') {
return '<pre class="readme">' . $this->readme . '</pre>';
$readme = preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1">$1</a>', $this->readme);
return '<pre class="readme">' . $readme . '</pre>';
}
}
return '';