Changeset 1002


Ignore:
Timestamp:
01/09/06 21:30:21 (14 years ago)
Author:
nikrou
Message:

-bug 259 fixed: optimize parse_comment_content() including links

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_5/include/functions_html.inc.php

    r975 r1002  
    402402{ 
    403403  $content = nl2br($content); 
     404 
     405  $pattern = '/(http?:\/\/\S*)/'; 
     406  $replacement = '<a href="$1">$1</a>'; 
     407  $content = preg_replace($pattern, $replacement, $content); 
    404408   
    405409  // replace _word_ by an underlined word 
    406   $pattern = '/_([^\s]*)_/'; 
    407   $replacement = '<span style="text-decoration:underline;">\1</span>'; 
     410  $pattern = '/\b_(\S*)_\b/'; 
     411  $replacement = '<span style="text-decoration:underline;">$1</span>'; 
    408412  $content = preg_replace($pattern, $replacement, $content); 
    409413   
    410414  // replace *word* by a bolded word 
    411   $pattern = '/\*([^\s]*)\*/'; 
    412   $replacement = '<span style="font-weight:bold;">\1</span>'; 
     415  $pattern = '/\b\*(\S*)\*\b/'; 
     416  $replacement = '<span style="font-weight:bold;">$1</span>'; 
    413417  $content = preg_replace($pattern, $replacement, $content); 
    414418   
    415419  // replace /word/ by an italic word 
    416   $pattern = '/\/([^\s]*)\//'; 
    417   $replacement = '<span style="font-style:italic;">\1</span>'; 
    418   $content = preg_replace($pattern, $replacement, $content); 
     420   $pattern = "/\/(\S*)\/(\s)/"; 
     421   $replacement = '<span style="font-style:italic;">$1$2</span>'; 
     422   $content = preg_replace($pattern, $replacement, $content); 
    419423 
    420424  return $content; 
Note: See TracChangeset for help on using the changeset viewer.