]> git.mxchange.org Git - friendica.git/commitdiff
fix a few issues with code blocks, ignore tags within blocks, fold multi-line blocks...
authorFriendika <info@friendika.com>
Mon, 24 Jan 2011 00:29:30 +0000 (16:29 -0800)
committerFriendika <info@friendika.com>
Mon, 24 Jan 2011 00:29:30 +0000 (16:29 -0800)
boot.php
mod/item.php
tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
tinymce/jscripts/tiny_mce/themes/advanced/skins/default/content.css

index 05b33abd6ef93d1d4d3f5cea4e5e0e5d8e806065..45fd8d16fe9345ee89e27c6c9cedb241916be669 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -1687,6 +1687,11 @@ function activity_match($haystack,$needle) {
 if(! function_exists('get_tags')) {
 function get_tags($s) {
        $ret = array();
+
+       // ignore anything in a code block
+
+       $s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s);
+
        if(preg_match_all('/([@#][^ \x0D\x0A,:?]*)([ \x0D\x0A,:?]|$)/',$s,$match)) {
                foreach($match[1] as $match) {
                        if(strstr($match,"]")) {
index f964e7737db2ab4f87ffaebf35aa2c3d090160f8..feef7c95f8f5f3cea88e23579110e81b292bd130 100644 (file)
@@ -165,7 +165,11 @@ function item_post(&$a) {
                }
        }
 
+       /**
+        * Fold multi-line [code] sequences
+        */
 
+       $body = preg_replace('/\[\/code\]\s*\[code\]/m',"\n",$body); 
 
        /**
         * Look for any tags and linkify them
index 8728f0c0f3286af70e31fccc17fd6d7436691019..f12975ba218e87258ed16f321774e1a981596dcf 100644 (file)
@@ -64,8 +64,8 @@
                        rep(/<u>/gi,"[u]");\r
                        rep(/<blockquote[^>]*>/gi,"[quote]");\r
                        rep(/<\/blockquote>/gi,"[/quote]");\r
-                       rep(/<br \/>/gi,"\n");\r
-                       rep(/<br\/>/gi,"\n");\r
+                       rep(/<br \/>/gi,"\n\n");\r
+                       rep(/<br\/>/gi,"\n\n");\r
                        rep(/<br>/gi,"\n");\r
                        rep(/<p>/gi,"");\r
                        rep(/<\/p>/gi,"\n");\r
@@ -98,6 +98,7 @@
                        rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");\r
                        rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");\r
                        rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<span style=\"color: $1;\">$2</span>");\r
+//                     rep(/\[\/code\]\s*\[code\]/gi,"<br />"); // fold multiline code\r
                        rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");\r
                        rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");\r
 \r
index 36f38aba296a50bf8e8321df4d4b57ddc9a01c96..444063a828673aab64825e4e59a04fbd15f4e5e2 100644 (file)
@@ -18,6 +18,18 @@ del {color:red; text-decoration:line-through}
 cite {border-bottom:1px dashed blue}\r
 acronym {border-bottom:1px dotted #CCC; cursor:help}\r
 abbr {border-bottom:1px dashed #CCC; cursor:help}\r
+code {\r
+       font-family: Courier, monospace;\r
+       white-space: pre;\r
+       display: block;\r
+       overflow: auto;\r
+       border: 1px solid #444;\r
+       background: #EEE;\r
+       color: #444;\r
+       padding: 10px;\r
+       margin-top: 20px;\r
+}\r
+\r
 \r
 /* IE */\r
 * html body {\r