+function tryoembed($match){
+ $url = ((count($match)==2)?$match[1]:$match[2]);
+// logger("tryoembed: $url");
+
+ $o = oembed_fetch_url($url);
+
+ //echo "<pre>"; var_dump($match, $url, $o); killme();
+
+ if ($o->type=="error") return $match[0];
+
+ $html = oembed_format_object($o);
+ return $html; //oembed_iframe($html,$o->width,$o->height);
+
+}
+
+// [noparse][i]italic[/i][/noparse] turns into
+// [noparse][ i ]italic[ /i ][/noparse],
+// to hide them from parser.
+
+function bb_spacefy($st) {
+ $whole_match = $st[0];
+ $captured = $st[1];
+ $spacefied = preg_replace("/\[(.*?)\]/", "[ $1 ]", $captured);
+ $new_str = str_replace($captured, $spacefied, $whole_match);
+ return $new_str;
+}
+
+// The previously spacefied [noparse][ i ]italic[ /i ][/noparse],
+// now turns back and the [noparse] tags are trimed
+// returning [i]italic[/i]
+
+function bb_unspacefy_and_trim($st) {
+ $whole_match = $st[0];
+ $captured = $st[1];
+ $unspacefied = preg_replace("/\[ (.*?)\ ]/", "[$1]", $captured);
+ return $unspacefied;
+}