diff options
Diffstat (limited to 'include/bb2diaspora.php')
-rwxr-xr-x | include/bb2diaspora.php | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index c26b0c334..9acd1e066 100755 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -13,30 +13,45 @@ require_once('include/html2bbcode.php'); function diaspora2bb($s) { + // for testing purposes: Collect raw markdown articles + $file = tempnam("/tmp/", "markdown"); + file_put_contents($file, $s); + $s = html_entity_decode($s,ENT_COMPAT,'UTF-8'); - $s = str_replace("\r","\n",$s); + + // Too many new lines. So deactivated the following line + // $s = str_replace("\r","\n",$s); + // Simply remove cr. + $s = str_replace("\r","",$s); $s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s); - $s = preg_replace('/\#([^\s\#])/','\\#$1',$s); + // Escaping the hash tags - doesn't always seem to work + // $s = preg_replace('/\#([^\s\#])/','\\#$1',$s); + // This seems to work + $s = preg_replace('/\#([^\s\#])/','#$1',$s); $s = Markdown($s); - $s = str_replace('#','#',$s); - $s = str_replace("\n",'<br />',$s); + $s = str_replace('#','#',$s); + + // Again: too many new lines + //$s = str_replace("\n",'<br />',$s); $s = html2bbcode($s); // $s = str_replace('*','*',$s); - $s = preg_replace("/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism",'[youtube]$2[/youtube]',$s); - $s = preg_replace("/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism",'[youtube]$1[/youtube]',$s); + $s = preg_replace("/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism",'[youtube]$2[/youtube]',$s); + $s = preg_replace("/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism",'[youtube]$1[/youtube]',$s); $s = preg_replace("/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism",'[vimeo]$2[/vimeo]',$s); $s = preg_replace("/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism",'[vimeo]$1[/vimeo]',$s); $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url]$2$3$4[/url]',$s); // remove duplicate adjacent code tags $s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); - $s = scale_diaspora_images($s); + + // Don't show link to full picture (until it is fixed) + $s = scale_diaspora_images($s, false); return $s; } |