-bug 259 fixed: optimize parse_comment_content() including links
git-svn-id: http://piwigo.org/svn/branches/branch-1_5@1002 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
22387e0d9b
commit
6d45ca83ef
1 changed files with 11 additions and 7 deletions
|
@ -401,21 +401,25 @@ function get_html_menu_category($categories)
|
|||
function parse_comment_content($content)
|
||||
{
|
||||
$content = nl2br($content);
|
||||
|
||||
$pattern = '/(http?:\/\/\S*)/';
|
||||
$replacement = '<a href="$1">$1</a>';
|
||||
$content = preg_replace($pattern, $replacement, $content);
|
||||
|
||||
// replace _word_ by an underlined word
|
||||
$pattern = '/_([^\s]*)_/';
|
||||
$replacement = '<span style="text-decoration:underline;">\1</span>';
|
||||
$pattern = '/\b_(\S*)_\b/';
|
||||
$replacement = '<span style="text-decoration:underline;">$1</span>';
|
||||
$content = preg_replace($pattern, $replacement, $content);
|
||||
|
||||
// replace *word* by a bolded word
|
||||
$pattern = '/\*([^\s]*)\*/';
|
||||
$replacement = '<span style="font-weight:bold;">\1</span>';
|
||||
$pattern = '/\b\*(\S*)\*\b/';
|
||||
$replacement = '<span style="font-weight:bold;">$1</span>';
|
||||
$content = preg_replace($pattern, $replacement, $content);
|
||||
|
||||
// replace /word/ by an italic word
|
||||
$pattern = '/\/([^\s]*)\//';
|
||||
$replacement = '<span style="font-style:italic;">\1</span>';
|
||||
$content = preg_replace($pattern, $replacement, $content);
|
||||
$pattern = "/\/(\S*)\/(\s)/";
|
||||
$replacement = '<span style="font-style:italic;">$1$2</span>';
|
||||
$content = preg_replace($pattern, $replacement, $content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue