aboutsummaryrefslogtreecommitdiffstats
path: root/include/bb2diaspora.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/bb2diaspora.php')
-rw-r--r--include/bb2diaspora.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index da02d6cac..87a8551ae 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -130,6 +130,9 @@ function markdown_to_bb($s, $use_zrl = false) {
$s = html_entity_decode($s,ENT_COMPAT,'UTF-8');
+ // if empty link text replace with the url
+ $s = preg_replace("/\[\]\((.*?)\)/ism",'[$1]($1)',$s);
+
// first try plustags
$s = preg_replace_callback('/\@\{(.+?)\; (.+?)\@(.+?)\}\+/','diaspora_mention_callback',$s);
@@ -155,10 +158,10 @@ function markdown_to_bb($s, $use_zrl = false) {
// Convert everything that looks like a link to a link
if($use_zrl) {
$s = str_replace(array('[img','/img]'),array('[zmg','/zmg]'),$s);
- $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[zrl=$2$3]$2$3[/zrl]',$s);
+ $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\(\)]+)/ism", '$1[zrl=$2$3]$2$3[/zrl]',$s);
}
else {
- $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3]$2$3[/url]',$s);
+ $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\(\)]+)/ism", '$1[url=$2$3]$2$3[/url]',$s);
}
// remove duplicate adjacent code tags
@@ -427,6 +430,12 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
$Text = preg_replace_callback('/\@\!?\[([zu])rl\=(\w+.*?)\](\w+.*?)\[\/([zu])rl\]/i', 'bb2dmention_callback', $Text);
+ // strip map tags, as the rendering is performed in bbcode() and the resulting output
+ // is not compatible with Diaspora (at least in the case of openstreetmap and probably
+ // due to the inclusion of an html iframe)
+
+ $Text = preg_replace("/\[map\=(.*?)\]/ism", '$1', $Text);
+ $Text = preg_replace("/\[map\](.*?)\[\/map\]/ism", '$1', $Text);
// Converting images with size parameters to simple images. Markdown doesn't know it.
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $Text);