Changeset 406 for trunk/plugins/GetHtml


Ignore:
Timestamp:
10/28/05 18:29:21 (14 years ago)
Author:
wymsy
Message:

Preserve formatting in comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/GetHtml/get-html.js

    r384 r406  
    1313  *   - Formats html in an indented, readable format in html mode 
    1414  *   - Preserves script and pre formatting 
     15  *   - Preserves formatting in comments 
    1516  *   - Removes contenteditable from body tag in full-page mode 
    1617  *   - Supports only7BitPrintablesInURLs config option 
     
    4647/*13*/  new RegExp().compile(/((href|src)=")([^\s]*)"/g), //find href and src for stripBaseHref() 
    4748/*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)[^>]*>/g), 
    48 /*15*/  new RegExp().compile(/<\/(div|p|h[1-6]|table|tr|td|th|ul|ol|li|blockquote|object|html|head|body)( [^>]*)?>/g),//blocklevel closing tag 
    49 /*16*/  new RegExp().compile(/<(div|p|h[1-6]|table|tr|td|th|ul|ol|li|blockquote|object|html|head|body)( [^>]*)?>/g),//blocklevel opening tag 
    50 /*17*/  new RegExp().compile(/<(br|hr|img|embed|param|pre|script)[^>]*>/g),//singlet tag 
     49/*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 tag 
     50/*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 tag 
     51/*17*/  new RegExp().compile(/<(br|hr|img|embed|param|pre)[^>]*>/g),//singlet tag 
    5152/*18*/  new RegExp().compile(/(^|<\/(pre|script)>)(\s|[^\s])*?(<(pre|script)[^>]*>|$)/g),//exclude content between pre and script tags 
    52 /*19*/  new RegExp().compile(/(<pre[^>]*>)(\s|[^\s])*?(<\/pre>)/g)//find content inside pre tags 
     53/*19*/  new RegExp().compile(/(<pre[^>]*>)(\s|[^\s])*?(<\/pre>)/g),//find content inside pre tags 
     54/*20*/  new RegExp().compile(/(^|<!--(\s|\S)*?-->)((\s|\S)*?)(?=<!--(\s|\S)*?-->|$)/g)//exclude comments 
    5355]; 
    5456 
     
    9294                s = s.replace(c[19], function(str){return str.replace(/<br \/>/g,"\n")}); 
    9395        } 
    94         s = s.replace(c[18], function(string) { 
     96        s = s.replace(c[20], function(st,$1,$2,$3) { //exclude comments 
     97          strn = $3.replace(c[18], function(string) { //skip pre and script tags 
    9598                string = string.replace(/[\n\r]/gi, " ").replace(/\s+/gi," ").replace(c[14], function(str) { 
    9699                        if (str.match(c[16])) { 
     
    115118                }); 
    116119                return string; 
     120      });return $1 + strn; 
    117121    }); 
    118122    if (s.charAt(0) == "\n") { 
     
    134138                        temp.appendChild(j.cloneNode(true)); 
    135139            } 
    136             html += temp.innerHTML.replace(/<[^\?][^>]*>/gi, function(tag){return editor.cleanHTML(tag)}); 
     140            html += temp.innerHTML.replace(/<[^\?!][^>]*>/gi, function(tag){return editor.cleanHTML(tag)}); 
    137141 
    138142        } else { 
     
    143147        } 
    144148 
    145         //pass tags to cleanHTML() one at a time; ignore php tags 
     149        //pass tags to cleanHTML() one at a time; ignore comments and php tags 
    146150        //includes support for htmlRemoveTags config option 
    147         html += editor.getInnerHTML().replace(/<[^\?][^>]*>/gi, function(tag){ 
     151        html += editor.getInnerHTML().replace(/<[^\?!][^>]*>/gi, function(tag){ 
    148152                if(!(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(tag.replace(/<([^\s>\/]+)/,'$1')))) 
    149153                return editor.cleanHTML(tag); 
     
    159163        } 
    160164        html = HTMLArea.indent(html); 
    161 } 
     165}; 
    162166//      html = HTMLArea.htmlEncode(html); 
    163167 
Note: See TracChangeset for help on using the changeset viewer.