- else
- $Text = bbcode($Text, $preserve_nl, false, 4);
-
- // Now convert HTML to Markdown
- $md = new Markdownify(false, false, false);
- $Text = $md->parseString($Text);
-
- // The Markdownify converter converts underscores '_' in URLs to '\_', which
- // messes up the URL. Manually fix these
- $count = 1;
- $pos = bb_find_open_close($Text, '[', ']', $count);
- while($pos !== false) {
- $start = substr($Text, 0, $pos['start']);
- $subject = substr($Text, $pos['start'], $pos['end'] - $pos['start'] + 1);
- $end = substr($Text, $pos['end'] + 1);
-
- $subject = str_replace('\_', '_', $subject);
- $Text = $start . $subject . $end;
-
- $count++;
- $pos = bb_find_open_close($Text, '[', ']', $count);
- }
-
- // If the text going into bbcode() has a plain URL in it, i.e.
- // with no [url] tags around it, it will come out of parseString()
- // looking like: <http://url.com>, which gets removed by strip_tags().
- // So take off the angle brackets of any such URL
- $Text = preg_replace("/<http(.*?)>/is", "http$1", $Text);
-
- // Remove all unconverted tags
- $Text = strip_tags($Text);
-
-
-/* Old routine
-
- $ev = bbtoevent($Text);
-
- // Replace any html brackets with HTML Entities to prevent executing HTML or script
- // Don't use strip_tags here because it breaks [url] search by replacing & with amp
-
- $Text = str_replace("<", "<", $Text);
- $Text = str_replace(">", ">", $Text);
-
- // If we find any event code, turn it into an event.
- // After we're finished processing the bbcode we'll
- // replace all of the event code with a reformatted version.
-
- if($preserve_nl)
- $Text = str_replace(array("\n","\r"), array('',''),$Text);
- else
- // Remove the "return" character, as Diaspora uses only the "newline"
- // character, so having the "return" character can cause signature
- // failures
- $Text = str_replace("\r", "", $Text);
-
-
- // Set up the parameters for a URL search string
- $URLSearchString = "^\[\]";
- // Set up the parameters for a MAIL search string
- $MAILSearchString = $URLSearchString;
-
- // Perform URL Search
-
- // [img]pathtoimage[/img]
-
- // the following was added on 10-January-2012 due to an inability of Diaspora's
- // new javascript markdown processor to handle links with images as the link "text"
- // It is not optimal and may be removed if this ability is restored in the future
-
- $Text = preg_replace("/\[url\=([$URLSearchString]*)\]\[img\](.*?)\[\/img\]\[\/url\]/ism",
- '![' . t('image/photo') . '](' . '$2' . ')' . "\n" . '[' . t('link') . '](' . '$1' . ')', $Text);
-
- $Text = preg_replace("/\[bookmark\]([$URLSearchString]*)\[\/bookmark\]/ism", '[$1]($1)', $Text);
- $Text = preg_replace("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism", '[$2]($1)', $Text);
-
- $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '[$1]($1)', $Text);
- $Text = preg_replace("/\#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[#$2]($1)', $Text);
- $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[$2]($1)', $Text);
-