Libertree: Improve the format of postings
authorMichael Vogel <icarus@dabo.de>
Mon, 18 Jun 2012 19:54:35 +0000 (21:54 +0200)
committerMichael Vogel <icarus@dabo.de>
Mon, 18 Jun 2012 19:54:35 +0000 (21:54 +0200)
libertree/libertree.php

index f57c773b394588c05730a90854ab93d95d53c848..fc9dcc44d0b6af0823b505a1647bc6b28af5735e 100755 (executable)
@@ -172,11 +172,25 @@ function libertree_send(&$a,&$b) {
                $title = $b['title'];
                $body = $b['body'];
 
+               // Insert a newline before and after a quote
+               $body = str_ireplace("[quote", "\n\n[quote", $body);
+               $body = str_ireplace("[/quote]", "[/quote]\n\n", $body);
+
+               // remove multiple newlines
+               do {
+                       $oldbody = $body;
+                        $body = str_replace("\n\n\n", "\n\n", $body);
+                } while ($oldbody != $body);
+
+               // convert to markdown
+               $body = bb2diaspora($body);
+
+               // Adding the title
                if(strlen($title))
-                       $body = "[b]".html_entity_decode($title)."[/b]\n\n".$body;
+                       $body = "## ".html_entity_decode($title)."\n\n".$body;
 
                $params = array(
-                       'text' => bb2diaspora($body)
+                       'text' => $body
                //      'token' => $ltree_api_token
                );