Ticket #891: bbcode.diff

File bbcode.diff, 1.3 KB (added by MichaelRoberts, 15 years ago)
  • html/inc/text_transform.inc

     
    122122        "@\[quote\](.*?)\[/quote\]@is",
    123123        "@\[list\](.*?)\[/list\]@is",
    124124        "@\[list=1\](.*?)\[/list\]@is", 
    125         "@\[pre\](.*?)\[/pre\]@is",
     125        "@\[pre\](.*?)\[/pre\]@eis",
    126126        "@\[img\]$urlregex\[/img\]@is",
    127127        "@\[color=(?:\"?)(.{3,8})(?:\"?)\](.*?)\[/color\]@is",
    128128        "@((?:<ol>|<ul>).*?)\n\*([^\n]+)\n(.*?(</ol>|</ul>))@is",
     
    153153        "<blockquote class='postbody'>\\1</blockquote>",
    154154        "<ul>\\1</ul><p>",
    155155        "<ol>\\1</ol><p>",
    156         "<pre>\\1</pre>",
     156        "'<pre>'.remove_br('\\1').'</pre>'",
    157157        "<img src=\"http://\\2\">",
    158158        "<font color=\"\\1\">\\2</font>",
    159159        "\\1<li>\\2\n\\3",
     
    186186    return str_replace("[", "&#91;", $text);
    187187}
    188188
     189/**
     190 * Removes any <br> tags added by nl2br which are not wanted, for example inside <pre> containers
     191 * The original \n was retained after the br when it was added
     192 **/
     193function remove_br($text){
     194    return str_replace("<br />", "", $text);
     195}
     196
    189197// Make links open in new windows.
    190198function externalize_links($text) {
    191199    // TODO:  Convert this to PCRE