8 function html2bbcode($s) {
11 // only keep newlines from source that are within pre tags
13 $s = stripnl_exceptinpre($s);
19 '/\<pre\>(.*?)\<\/pre\>/is',
22 '/\<b\>(.*?)\<\/b\>/is',
23 '/\<i\>(.*?)\<\/i\>/is',
24 '/\<u\>(.*?)\<\/u\>/is',
25 '/\<ul\>(.*?)\<\/ul\>/is',
26 '/\<li\>(.*?)\<\/li\>/is',
27 '/\<img(.*?) src=\"(.*?)\" (.*?)\>/is',
28 '/\<div(.*?)\>(.*?)\<\/div\>/is',
30 '/\<strong\>(.*?)\<\/strong\>/is',
31 '/\<a (.*?)href=\"(.*?)\"(.*?)\>(.*?)\<\/a\>/is',
32 '/\<code\>(.*?)\<\/code\>/is',
33 '/\<span style=\"color:(.*?)\"\>(.*?)\<\/span\>/is',
34 '/\<span style=\"font-size:(.*?)\"\>(.*?)\<\/span\>/is',
35 '/\<blockquote\>(.*?)\<\/blockquote\>/is',
36 '/\<video(.*?) src=\"(.*?)\" (.*?)\>(.*?)\<\/video\>/is',
37 '/\<audio(.*?) src=\"(.*?)\" (.*?)\>(.*?)\<\/audio\>/is',
58 '[color="$1"]$2[/color]',
65 // Replace $htmltags in $text with $bbtags
66 $text = preg_replace ($htmltags, $bbtags, $s);
68 call_hooks('html2bbcode', $text);
70 // Strip all other HTML tags
71 $text = strip_tags($text);
76 function stripnl_exceptinpre($string)
78 // First, check for <pre> tag
79 if(strpos($string, '<pre>') === false)
81 return str_replace("\n","", $string);
84 // If there is a <pre>, we have to split by line
85 // and manually replace the linebreaks
87 $strArr=explode("\n", $string);
92 // Loop over each line
93 foreach($strArr as $line)
94 { // See if the line has a <pre>. If it does, set $preFound to true
95 if(strpos($line, "<pre>") !== false)
99 elseif(strpos($line, "</pre>") !== false)
104 // If we are in a pre tag, add line and also add \n, else add the line without \n
107 $output .= $line . "\n";