From cb9d0993f195841a5d8adcaed4faeb7423f13a14 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 24 Feb 2012 20:07:57 -0800 Subject: waitman gobble fix for escaping code blocks in tinymce --- .../tiny_mce/plugins/bbcode/editor_plugin_src.js | 73 +++++++++++++++++++--- 1 file changed, 65 insertions(+), 8 deletions(-) (limited to 'library/tinymce/jscripts/tiny_mce') diff --git a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js index e5f716b29..44d1473a9 100755 --- a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js +++ b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js @@ -44,9 +44,35 @@ _dfrn_html2bbcode : function(s) { s = tinymce.trim(s); - function rep(re, str) { - s = s.replace(re, str); - }; + 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]"); + + }; @@ -123,11 +149,42 @@ // BBCode -> HTML from DFRN dialect _dfrn_bbcode2html : function(s) { s = tinymce.trim(s); - - function rep(re, str) { - s = s.replace(re, str); - }; - + + + 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 rep(/\n/gi,"
"); rep(/\[b\]/gi,""); -- cgit v1.2.3