diff options
author | friendica <info@friendica.com> | 2012-10-22 19:46:18 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-10-22 19:46:18 -0700 |
commit | a7abe24382bac00243fd19ebc2cdde87569eab79 (patch) | |
tree | 2e802f3357af5e13407241e1c94a17f5e7962517 /include/bbcode.php | |
parent | 896ca97330f86afe3ab9c7a07ae6d1676c1a546a (diff) | |
download | volse-hubzilla-a7abe24382bac00243fd19ebc2cdde87569eab79.tar.gz volse-hubzilla-a7abe24382bac00243fd19ebc2cdde87569eab79.tar.bz2 volse-hubzilla-a7abe24382bac00243fd19ebc2cdde87569eab79.zip |
more file cleanup
Diffstat (limited to 'include/bbcode.php')
-rw-r--r-- | include/bbcode.php | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index b383f43b6..dd0cc6958 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -5,23 +5,15 @@ require_once('include/event.php'); -function stripcode_br_cb($s) { - return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]'; -} - -function tryoembed($match){ +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); - + return $html; } // [noparse][i]italic[/i][/noparse] turns into @@ -115,25 +107,26 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $a = get_app(); + // Extract the private images which use data url's since preg has issues with + // large data sizes. Stash them away while we do bbcode conversion, and then put them back + // in after we've done all the regex matching. We cannot use any preg functions to do this. + + $extracted = bb_extract_images($Text); + $Text = $extracted['body']; + $saved_image = $extracted['images']; + + // Move all spaces out of the tags $Text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $Text); $Text = preg_replace("/(\s*)\[\/(\w*)\]/ism", '[/$2]$1', $Text); // Hide all [noparse] contained bbtags by spacefying them - // POSSIBLE BUG --> Will the 'preg' functions crash if there's an embedded image? $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_spacefy',$Text); $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_spacefy',$Text); $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text); - // Extract the private images which use data url's since preg has issues with - // large data sizes. Stash them away while we do bbcode conversion, and then put them back - // in after we've done all the regex matching. We cannot use any preg functions to do this. - - $extracted = bb_extract_images($Text); - $Text = $extracted['body']; - $saved_image = $extracted['images']; // If we find any event code, turn it into an event. // After we're finished processing the bbcode we'll @@ -266,8 +259,6 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // Declare the format for [code] layout -// $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism",'stripcode_br_cb',$Text); - $CodeLayout = '<code>$1</code>'; // Check for [code] text $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism","$CodeLayout", $Text); |