]> git.mxchange.org Git - friendica.git/commitdiff
waitman gobble fix for escaping code blocks in tinymce
authorfriendica <info@friendica.com>
Sat, 25 Feb 2012 04:07:57 +0000 (20:07 -0800)
committerfriendica <info@friendica.com>
Sat, 25 Feb 2012 04:07:57 +0000 (20:07 -0800)
library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js

index e5f716b297e6cb58e494c2d29b9c341e4939041f..44d1473a99fe2bbe5b6c739f2a84d035bd297bb5 100755 (executable)
                _dfrn_html2bbcode : function(s) {\r
                        s = tinymce.trim(s);\r
 \r
-                       function rep(re, str) {\r
-                               s = s.replace(re, str);\r
-                       };\r
+                       function rep(re, str) {
+
+                               //modify code to keep stuff intact within [code][/code] blocks
+                               //Waitman Gobble NO WARRANTY
+
+
+                               var o = new Array();
+                               var x = s.split("[code]");
+                               var i = 0;
+
+                               var si = "";
+                               si = x.shift();
+                               si = si.replace(re,str);
+                               o.push(si);
+
+                               for (i = 0; i < x.length; i++) {
+                                       var no = new Array();
+                                       var j = x.shift();
+                                       var g = j.split("[/code]");
+                                       no.push(g.shift());
+                                       si = g.shift();
+                                       si = si.replace(re,str);
+                                       no.push(si);
+                                       o.push(no.join("[/code]"));
+                               }
+
+                               s = o.join("[code]");
+
+                       };
 
 
 
                // BBCode -> HTML from DFRN dialect\r
                _dfrn_bbcode2html : function(s) {\r
                        s = tinymce.trim(s);\r
-\r
-                       function rep(re, str) {\r
-                               s = s.replace(re, str);\r
-                       };\r
-\r
+
+
+                        function rep(re, str) {
+
+                                //modify code to keep stuff intact within [code][/code] blocks
+                                //Waitman Gobble NO WARRANTY
+
+
+                                var o = new Array();
+                                var x = s.split("[code]");
+                                var i = 0;
+
+                                var si = "";
+                                si = x.shift();
+                                si = si.replace(re,str);
+                                o.push(si);
+
+                                for (i = 0; i < x.length; i++) {
+                                        var no = new Array();
+                                        var j = x.shift();
+                                        var g = j.split("[/code]");
+                                        no.push(g.shift());
+                                        si = g.shift();
+                                        si = si.replace(re,str);
+                                        no.push(si);
+                                        o.push(no.join("[/code]"));
+                                }
+
+                                s = o.join("[code]");
+
+                        };
+
+
+
+
+
                        // example: [b] to <strong>\r
                        rep(/\n/gi,"<br />");\r
                        rep(/\[b\]/gi,"<strong>");\r