aboutsummaryrefslogtreecommitdiffstats
path: root/include/bb2diaspora.php
diff options
context:
space:
mode:
authorMichael <icarus@dabo.de>2012-02-19 20:36:59 +0100
committerMichael <icarus@dabo.de>2012-02-19 20:36:59 +0100
commit31653aef64c94ade956b552dad65bfe15f0ad491 (patch)
treef79bd0d84484910a5b545d62946711ba0550c54b /include/bb2diaspora.php
parent4713069e68e163971f2625500f9006501e59bd04 (diff)
downloadvolse-hubzilla-31653aef64c94ade956b552dad65bfe15f0ad491.tar.gz
volse-hubzilla-31653aef64c94ade956b552dad65bfe15f0ad491.tar.bz2
volse-hubzilla-31653aef64c94ade956b552dad65bfe15f0ad491.zip
Brand new html2bbcode. Some other changes in diaspora to bbcode handling
Diffstat (limited to 'include/bb2diaspora.php')
-rwxr-xr-xinclude/bb2diaspora.php29
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\#])/','&#35;$1',$s);
$s = Markdown($s);
- $s = str_replace('&#35;','#',$s);
- $s = str_replace("\n",'<br />',$s);
+ $s = str_replace('&#35;','#',$s);
+
+ // Again: too many new lines
+ //$s = str_replace("\n",'<br />',$s);
$s = html2bbcode($s);
// $s = str_replace('&#42;','*',$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;
}