1 /* Import plugin specific language pack */
2 tinyMCE.importPluginLanguagePack('wordpress', 'en');
4 var TinyMCE_wordpressPlugin = {
7 longname : 'WordPress Plugin',
9 authorurl : 'http://wordpress.org',
10 infourl : 'http://wordpress.org',
15 getControlHTML : function(control_name) {
16 switch (control_name) {
18 return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_more_button', '{$pluginurl}/images/more.gif', 'wpMore');
20 return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_page_button', '{$pluginurl}/images/page.gif', 'wpPage');
22 var buttons = tinyMCE.getButtonHTML(control_name, 'lang_help_button_title', '{$pluginurl}/images/help.gif', 'wpHelp');
23 var hiddenControls = '<div class="zerosize">'
24 + '<input type="button" accesskey="n" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSpellCheck\',false);" />'
25 + '<input type="button" accesskey="k" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Strikethrough\',false);" />'
26 + '<input type="button" accesskey="l" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertUnorderedList\',false);" />'
27 + '<input type="button" accesskey="o" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertOrderedList\',false);" />'
28 + '<input type="button" accesskey="w" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Outdent\',false);" />'
29 + '<input type="button" accesskey="q" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Indent\',false);" />'
30 + '<input type="button" accesskey="f" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyLeft\',false);" />'
31 + '<input type="button" accesskey="c" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyCenter\',false);" />'
32 + '<input type="button" accesskey="r" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyRight\',false);" />'
33 + '<input type="button" accesskey="j" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyFull\',false);" />'
34 + '<input type="button" accesskey="a" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceLink\',true);" />'
35 + '<input type="button" accesskey="s" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'unlink\',false);" />'
36 + '<input type="button" accesskey="m" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceImage\',true);" />'
37 + '<input type="button" accesskey="t" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpMore\');" />'
38 + '<input type="button" accesskey="g" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpPage\');" />'
39 + '<input type="button" accesskey="u" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Undo\',false);" />'
40 + '<input type="button" accesskey="y" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Redo\',false);" />'
41 + '<input type="button" accesskey="h" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpHelp\',false);" />'
42 + '<input type="button" accesskey="b" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Bold\',false);" />'
43 + '<input type="button" accesskey="v" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpAdv\',false);" />'
45 return buttons+hiddenControls;
47 return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_adv_button', '{$pluginurl}/images/toolbars.gif', 'wpAdv');
49 return '<div id="wpadvbar" style="display:none;"><br />';
56 execCommand : function(editor_id, element, command, user_interface, value) {
57 var inst = tinyMCE.getInstanceById(editor_id);
58 var focusElm = inst.getFocusElement();
59 var doc = inst.getDoc();
61 function getAttrib(elm, name) {
62 return elm.getAttribute(name) ? elm.getAttribute(name) : "";
69 var template = new Array();
70 var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
72 // Is selection a image
73 if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
74 flag = getAttrib(focusElm, 'class');
76 if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
83 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
84 + ' width="100%" height="10px" '
85 + 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
86 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, html);
87 tinyMCE.selectedInstance.repaint();
92 var template = new Array();
93 var altPage = tinyMCE.getLang('lang_wordpress_more_alt');
95 // Is selection a image
96 if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
97 flag = getAttrib(focusElm, 'name');
99 if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
106 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
107 + ' width="100%" height="10px" '
108 + 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
109 tinyMCE.execCommand("mceInsertContent",true,html);
110 tinyMCE.selectedInstance.repaint();
114 var template = new Array();
116 template['file'] = tinyMCE.baseURL + '/wp-mce-help.php';
117 template['width'] = 480;
118 template['height'] = 380;
125 tinyMCE.openWindow(template, args);
128 var adv = document.getElementById('wpadvbar');
129 if ( adv.style.display == 'none' ) {
130 adv.style.display = 'block';
131 tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonSelected');
133 adv.style.display = 'none';
134 tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonNormal');
139 // Pass to next handler in chain
143 cleanup : function(type, content) {
146 case "insert_to_editor":
148 var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
149 var altPage = tinyMCE.getLang('lang_wordpress_page_alt');
151 // Parse all <!--more--> tags and replace them with images
152 while ((startPos = content.indexOf('<!--more', startPos)) != -1) {
153 var endPos = content.indexOf('-->', startPos) + 3;
155 var moreText = content.substring(startPos + 8, endPos - 3);
156 var contentAfter = content.substring(endPos);
157 content = content.substring(0, startPos);
158 content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
159 content += ' width="100%" height="10px" moretext="'+moreText+'" ';
160 content += 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
161 content += contentAfter;
167 // Parse all <!--page--> tags and replace them with images
168 while ((startPos = content.indexOf('<!--nextpage-->', startPos)) != -1) {
170 var contentAfter = content.substring(startPos + 15);
171 content = content.substring(0, startPos);
172 content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
173 content += ' width="100%" height="10px" ';
174 content += 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
175 content += contentAfter;
180 // Look for \n in <pre>, replace with <br>
182 while ((startPos = content.indexOf('<pre', startPos+1)) != -1) {
183 var endPos = content.indexOf('</pre>', startPos+1);
184 var innerPos = content.indexOf('>', startPos+1);
185 var chunkBefore = content.substring(0, innerPos);
186 var chunkAfter = content.substring(endPos);
188 var innards = content.substring(innerPos, endPos);
189 innards = innards.replace(/\n/g, '<br />');
190 content = chunkBefore + innards + chunkAfter;
195 case "get_from_editor":
196 // Parse all img tags and replace them with <!--more-->
198 while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
199 var endPos = content.indexOf('/>', startPos);
200 var attribs = this._parseAttributes(content.substring(startPos + 4, endPos));
202 if (attribs['class'] == "mce_plugin_wordpress_more" || attribs['name'] == "mce_plugin_wordpress_more") {
205 var moreText = attribs['moretext'] ? attribs['moretext'] : '';
206 var embedHTML = '<!--more'+moreText+'-->';
208 // Insert embed/object chunk
209 chunkBefore = content.substring(0, startPos);
210 chunkAfter = content.substring(endPos);
211 content = chunkBefore + embedHTML + chunkAfter;
213 if (attribs['class'] == "mce_plugin_wordpress_page" || attribs['name'] == "mce_plugin_wordpress_page") {
216 var embedHTML = '<!--nextpage-->';
218 // Insert embed/object chunk
219 chunkBefore = content.substring(0, startPos);
220 chunkAfter = content.substring(endPos);
221 content = chunkBefore + embedHTML + chunkAfter;
225 // Remove normal line breaks
226 content = content.replace(/\n|\r/g, ' ');
228 // Look for <br> in <pre>, replace with \n
230 while ((startPos = content.indexOf('<pre', startPos+1)) != -1) {
231 var endPos = content.indexOf('</pre>', startPos+1);
232 var innerPos = content.indexOf('>', startPos+1);
233 var chunkBefore = content.substring(0, innerPos);
234 var chunkAfter = content.substring(endPos);
236 var innards = content.substring(innerPos, endPos);
237 innards = innards.replace(new RegExp('<br\\s?/?>', 'g'), '\n');
238 innards = innards.replace(new RegExp('\\s$', ''), '');
239 content = chunkBefore + innards + chunkAfter;
242 // Remove anonymous, empty paragraphs.
243 content = content.replace(new RegExp('<p>(\\s| )*</p>', 'mg'), '');
245 // Handle table badness.
246 content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>');
247 content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>');
248 content = content.replace(new RegExp('</(td|th)>.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '</$1><$2>');
249 content = content.replace(new RegExp('</tr>.*?<(tr|/table)>', 'mg'), '</tr><$1>');
250 content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(<br ?/?>)*)*', 'g'), '<$1>');
252 // Pretty it up for the source editor.
253 var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p';
254 content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
255 content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>', 'mg'), '\n<$1>');
256 content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>');
257 content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>');
258 content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'mg'), '<br />\n');
259 content = content.replace(new RegExp('^\\s*', ''), '');
260 content = content.replace(new RegExp('\\s*$', ''), '');
265 // Pass through to next handler in chain
269 handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
271 tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonNormal');
272 tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonNormal');
278 if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
279 tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonSelected');
280 if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
281 tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonSelected');
282 } while ((node = node.parentNode));
287 saveCallback : function(el, content, body) {
288 // We have a TON of cleanup to do.
290 // Mark </p> if it has any attributes.
291 content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>');
293 // Decode the ampersands of time.
294 // content = content.replace(new RegExp('&', 'g'), '&');
296 // Get it ready for wpautop.
297 content = content.replace(new RegExp('\\s*<p>', 'mgi'), '');
298 content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n');
299 content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n');
300 content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
302 // Fix some block element newline issues
303 var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre';
304 content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
305 content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
306 content = content.replace(new RegExp('<li>', 'g'), '\t<li>');
308 // Unmark special paragraph closing tags
309 content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
310 content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1');
312 // Trim trailing whitespace
313 content = content.replace(new RegExp('\\s*$', ''), '');
320 _parseAttributes : function(attribute_string) {
321 var attributeName = "";
322 var attributeValue = "";
325 var attributes = new Array();
326 var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
327 var titleText = tinyMCE.getLang('lang_wordpress_more');
328 var titleTextPage = tinyMCE.getLang('lang_wordpress_page');
330 if (attribute_string == null || attribute_string.length < 2)
333 withInName = withInValue = false;
335 for (var i=0; i<attribute_string.length; i++) {
336 var chr = attribute_string.charAt(i);
338 if ((chr == '"' || chr == "'") && !withInValue)
340 else if ((chr == '"' || chr == "'") && withInValue) {
343 var pos = attributeName.lastIndexOf(' ');
345 attributeName = attributeName.substring(pos+1);
347 attributes[attributeName.toLowerCase()] = attributeValue.substring(1);
351 } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
354 if (chr == '=' && withInName)
358 attributeName += chr;
361 attributeValue += chr;
368 tinyMCE.addPlugin("wordpress", TinyMCE_wordpressPlugin);
370 /* This little hack protects our More and Page placeholders from the removeformat command */
371 tinyMCE.orgExecCommand = tinyMCE.execCommand;
372 tinyMCE.execCommand = function (command, user_interface, value) {
373 re = this.orgExecCommand(command, user_interface, value);
375 if ( command == 'removeformat' ) {
376 var inst = tinyMCE.getInstanceById('mce_editor_0');
378 var imgs = doc.getElementsByTagName('img');
379 for (i=0;img=imgs[i];i++)
380 img.className = img.name;
384 wpInstTriggerSave = function (skip_cleanup, skip_callback) {
385 var e, nl = new Array(), i, s;
387 this.switchSettings();
388 s = tinyMCE.settings;
390 // Force hidden tabs visible while serializing
391 if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
392 e = this.iframeElement;
395 if (e.style && e.style.display == 'none') {
396 e.style.display = 'block';
397 nl[nl.length] = {elm : e, type : 'style'};
400 if (e.style && s.hidden_tab_class.length > 0 && e.className.indexOf(s.hidden_tab_class) != -1) {
401 e.className = s.display_tab_class;
402 nl[nl.length] = {elm : e, type : 'class'};
404 } while ((e = e.parentNode) != null)
407 tinyMCE.settings['preformatted'] = false;
410 if (typeof(skip_cleanup) == "undefined")
411 skip_cleanup = false;
414 if (typeof(skip_callback) == "undefined")
415 skip_callback = false;
417 // tinyMCE._setHTML(this.getDoc(), this.getBody().innerHTML);
419 // Remove visual aids when cleanup is disabled
420 if (this.settings['cleanup'] == false) {
421 tinyMCE.handleVisualAid(this.getBody(), true, false, this);
422 tinyMCE._setEventsEnabled(this.getBody(), true);
425 tinyMCE._customCleanup(this, "submit_content_dom", this.contentWindow.document.body);
426 tinyMCE.selectedInstance.getWin().oldfocus=tinyMCE.selectedInstance.getWin().focus;
427 tinyMCE.selectedInstance.getWin().focus=function() {};
428 var htm = tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true);
429 tinyMCE.selectedInstance.getWin().focus=tinyMCE.selectedInstance.getWin().oldfocus;
430 htm = tinyMCE._customCleanup(this, "submit_content", htm);
432 if (!skip_callback && tinyMCE.settings['save_callback'] != "")
433 var content = eval(tinyMCE.settings['save_callback'] + "(this.formTargetElementId,htm,this.getBody());");
435 // Use callback content if available
436 if ((typeof(content) != "undefined") && content != null)
439 // Replace some weird entities (Bug: #1056343)
440 htm = tinyMCE.regexpReplace(htm, "(", "(", "gi");
441 htm = tinyMCE.regexpReplace(htm, ")", ")", "gi");
442 htm = tinyMCE.regexpReplace(htm, ";", ";", "gi");
443 htm = tinyMCE.regexpReplace(htm, """, """, "gi");
444 htm = tinyMCE.regexpReplace(htm, "^", "^", "gi");
446 if (this.formElement)
447 this.formElement.value = htm;
449 if (tinyMCE.isSafari && this.formElement)
450 this.formElement.innerText = htm;
452 // Hide them again (tabs in MSIE)
453 for (i=0; i<nl.length; i++) {
454 if (nl[i].type == 'style')
455 nl[i].elm.style.display = 'none';
457 nl[i].elm.className = s.hidden_tab_class;
460 tinyMCE.wpTriggerSave = function () {
462 for (n in tinyMCE.instances) {
463 inst = tinyMCE.instances[n];
464 if (!tinyMCE.isInstance(inst))
466 inst.wpTriggerSave = wpInstTriggerSave;
467 inst.wpTriggerSave(false, false);
471 function switchEditors(id) {
472 var inst = tinyMCE.getInstanceById(id);
473 var qt = document.getElementById('quicktags');
474 var H = document.getElementById('edButtonHTML');
475 var P = document.getElementById('edButtonPreview');
476 var ta = document.getElementById(id);
477 var pdr = ta.parentNode;
482 if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) {
483 // IE rejects the later overflow assignment so we skip this step.
484 // Alternate code might be nice. Until then, IE reflows.
486 // Lock the fieldset's height to prevent reflow/flicker
487 pdr.style.height = pdr.clientHeight + 'px';
488 pdr.style.overflow = 'hidden';
491 // Save the coords of the bottom right corner of the rich editor
492 var table = document.getElementById(inst.editorId + '_parent').getElementsByTagName('table')[0];
493 var y1 = table.offsetTop + table.offsetHeight;
495 if ( TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height") == null ) {
496 var expires = new Date();
497 expires.setTime(expires.getTime() + 3600000 * 24 * 30);
498 var offset = tinyMCE.isMSIE ? 1 : 2;
499 TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + inst.editorId + "_height", "" + (table.offsetHeight - offset), expires);
502 // Unload the rich editor
503 inst.triggerSave(false, false);
504 htm = inst.formElement.value;
505 tinyMCE.removeMCEControl(id);
506 document.getElementById(id).value = htm;
509 // Reveal Quicktags and textarea
510 qt.style.display = 'block';
511 ta.style.display = 'inline';
513 // Set the textarea height to match the rich editor
514 y2 = ta.offsetTop + ta.offsetHeight;
515 ta.style.height = (ta.clientHeight + y1 - y2) + 'px';
518 ta.parentNode.style.paddingRight = '12px';
520 if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) {
522 // Unlock the fieldset's height
523 pdr.style.height = 'auto';
524 pdr.style.overflow = 'display';
528 edCloseAllTags(); // :-(
530 if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) {
532 // Lock the fieldset's height
533 pdr.style.height = pdr.clientHeight + 'px';
534 pdr.style.overflow = 'hidden';
537 // Hide Quicktags and textarea
538 qt.style.display = 'none';
539 ta.style.display = 'none';
542 ta.parentNode.style.paddingRight = '0px';
544 // Load the rich editor with formatted html
545 if ( tinyMCE.isMSIE ) {
546 ta.value = wpautop(ta.value);
547 tinyMCE.addMCEControl(ta, id);
549 htm = wpautop(ta.value);
550 tinyMCE.addMCEControl(ta, id);
551 tinyMCE.getInstanceById(id).execCommand('mceSetContent', null, htm);
554 if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) {
556 // Unlock the fieldset's height
557 pdr.style.height = 'auto';
558 pdr.style.overflow = 'display';
563 function edToggle(A, B) {
564 A.className = 'edButtonFore';
565 B.className = 'edButtonBack';
567 B.onclick = A.onclick;
571 function wpautop(pee) {
573 pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\n\n");
574 pee = pee.replace(new RegExp('(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)', 'gi'), "\n$1");
575 pee = pee.replace(new RegExp('(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)', 'gi'), "$1\n\n");
576 pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
577 pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
578 pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n");
579 pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
580 pee = pee.replace(new RegExp('<p>\\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\\s*</p>', 'gi'), "$1");
581 pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
582 pee = pee.replace(new RegExp('<p><blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
583 pee = pee.replace(new RegExp('</blockquote></p>', 'gi'), '</p></blockquote>');
584 pee = pee.replace(new RegExp('<p>\\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)', 'gi'), "$1");
585 pee = pee.replace(new RegExp('(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\\s*</p>', 'gi'), "$1");
586 pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
587 pee = pee.replace(new RegExp('(</?(?:table|thead|tfoot|caption|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\\s*<br />', 'gi'), "$1");
588 pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
589 pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 ');
590 //pee = pee.replace(new RegExp('(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' "); // Hmm...