diff options
author | nikrou <nikrou@piwigo.org> | 2006-01-09 20:30:21 +0000 |
---|---|---|
committer | nikrou <nikrou@piwigo.org> | 2006-01-09 20:30:21 +0000 |
commit | 6d45ca83efc0f28bb00ecab1a9b4964279cc26b5 (patch) | |
tree | 6ddcab6acb896db36266baaf3dd3afb7cb40fd55 /include/functions_html.inc.php | |
parent | 22387e0d9b6654305552da23d9b2c2a9c134407b (diff) |
-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
Diffstat (limited to 'include/functions_html.inc.php')
-rw-r--r-- | include/functions_html.inc.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index ca8ae53e1..50a999854 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -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; } |