Changeset 515
- Timestamp:
- 05/16/06 15:17:40 (7 years ago)
- Files:
-
- 1 modified
-
trunk/plugins/GetHtml/get-html.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/GetHtml/get-html.js
r502 r515 47 47 /*12*/ new RegExp().compile(/(\S*\s*=\s*)?contenteditable[^=>]*(=\s*[^>\s\/]*)?/gi),//strip contenteditable 48 48 /*13*/ new RegExp().compile(/((href|src)=")([^\s]*)"/g), //find href and src for stripBaseHref() 49 /*14*/ new RegExp().compile(/<\/?(div|p|h[1-6]|table|tr|td|th|ul|ol|li|blockquote|object|br|hr|img|embed|param|pre|script|html|head|body|meta|link|title|area )[^>]*>/g),50 /*15*/ new RegExp().compile(/<\/(div|p|h[1-6]|table|tr| td|th|ul|ol|li|blockquote|object|html|head|body|script)( [^>]*)?>/g),//blocklevel closing tag51 /*16*/ new RegExp().compile(/<(div|p|h[1-6]|table|tr| td|th|ul|ol|li|blockquote|object|html|head|body|script)( [^>]*)?>/g),//blocklevel opening tag52 /*17*/ new RegExp().compile(/<( br|hr|img|embed|param|pre|meta|link|title|area)[^>]*>/g),//singlet tag49 /*14*/ new RegExp().compile(/<\/?(div|p|h[1-6]|table|tr|td|th|ul|ol|li|blockquote|object|br|hr|img|embed|param|pre|script|html|head|body|meta|link|title|area|input|form|textarea|select|option)[^>]*>/g), 50 /*15*/ new RegExp().compile(/<\/(div|p|h[1-6]|table|tr|ul|ol|blockquote|object|html|head|body|script|form|select)( [^>]*)?>/g),//blocklevel closing tag 51 /*16*/ new RegExp().compile(/<(div|p|h[1-6]|table|tr|ul|ol|blockquote|object|html|head|body|script|form|select)( [^>]*)?>/g),//blocklevel opening tag 52 /*17*/ new RegExp().compile(/<(td|th|li|option|br|hr|img|embed|param|pre|meta|link|title|area|input|textarea)[^>]*>/g),//singlet tag or output on 1 line 53 53 /*18*/ new RegExp().compile(/(^|<\/(pre|script)>)(\s|[^\s])*?(<(pre|script)[^>]*>|$)/g),//find content NOT inside pre and script tags 54 54 /*19*/ new RegExp().compile(/(<pre[^>]*>)(\s|[^\s])*?(<\/pre>)/g),//find content inside pre tags 55 55 /*20*/ new RegExp().compile(/(^|<!--(\s|\S)*?-->)((\s|\S)*?)(?=<!--(\s|\S)*?-->|$)/g),//find content NOT inside comments 56 56 /*21*/ new RegExp().compile(/\S*=""/g), //find empty attributes 57 /*22*/ new RegExp().compile(/<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<[^>]*>/g) //find all tags, including comments and php 57 /*22*/ new RegExp().compile(/<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<\/?\w[^>]*>/g), //find all tags, including comments and php 58 /*23*/ new RegExp().compile(/(^|<\/script>)(\s|[^\s])*?(<script[^>]*>|$)/g) //find content NOT inside script tags 58 59 ]; 59 60 … … 124 125 });return strn; 125 126 }); 126 if (s.charAt(0) == "\n") {127 return s.substring(1, s.length);128 }129 s = s.replace(/ *\n/g,'\n');//strip spaces at end of lines127 //final cleanup 128 s = s.replace(/^\s*/,'').//strip leading whitespace 129 replace(/ +\n/g,'\n').//strip spaces at end of lines 130 replace(/[\r\n]+<\/script>/g,'\n</script>');//strip returns added into scripts 130 131 return s; 131 132 }; … … 143 144 temp.appendChild(j.cloneNode(true)); 144 145 } 145 html += temp.innerHTML.replace(c[22], function(tag){ 146 if(/^<[!\?]/.test(tag)) return tag; //skip comments and php tags 147 else return editor.cleanHTML(tag)}); 146 html += temp.innerHTML.replace(c[23], function(strn) { //skip content inside script tags 147 strn = strn.replace(c[22], function(tag){ 148 if(/^<[!\?]/.test(tag)) return tag; //skip comments and php tags 149 else return editor.cleanHTML(tag)}); 150 return strn; 151 }); 148 152 149 153 } else { … … 171 175 //pass tags to cleanHTML() one at a time 172 176 //includes support for htmlRemoveTags config option 173 html += innerhtml.replace(c[22], function(tag){ 174 if(/^<[!\?]/.test(tag)) return tag; //skip comments and php tags 175 else if(!(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(tag.replace(/<([^\s>\/]+)/,'$1')))) 176 return editor.cleanHTML(tag); 177 else return ''}); 177 html += innerhtml.replace(c[23], function(strn) { //skip content inside script tags 178 strn = strn.replace(c[22], function(tag){ 179 if(/^<[!\?]/.test(tag)) return tag; //skip comments and php tags 180 else if(!(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(tag.replace(/<([^\s>\/]+)/,'$1')))) 181 return editor.cleanHTML(tag); 182 else return ''}); 183 return strn; 184 }); 178 185 //IE drops all </li> tags in a list except the last one 179 186 if(HTMLArea.is_ie) { … … 183 190 } 184 191 if(HTMLArea.is_gecko) 185 html = html.replace(/(.*)<br \/>\n$/, '$1'). //strip trailing <br> added by moz 186 replace(/^\n(.*)/, '$1'); //strip leading newline added by moz 192 html = html.replace(/<br \/>\n$/, ''); //strip trailing <br> added by moz 187 193 if (outputRoot) { 188 194 html += "</" + root_tag + ">"; … … 195 201 }; 196 202 197 //over ride (hack)outwardHtml() to handle onclick suppression203 //overload outwardHtml() to handle onclick suppression 198 204 HTMLArea.prototype._origOutwardHtml = HTMLArea.prototype.outwardHtml; 199 205 HTMLArea.prototype.outwardHtml = function(html) {
