Changeset 601 for trunk


Ignore:
Timestamp:
10/18/06 18:01:37 (13 years ago)
Author:
wymsy
Message:

Fix for ticket #847, plus simplified several other regexps

File:
1 edited

Legend:

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

    r515 r601  
    3333HTMLArea.RegExpCache = [ 
    3434/*00*/  new RegExp().compile(/<\s*\/?([^\s\/>]+)[\s*\/>]/gi),//lowercase tags 
    35 /*01*/  new RegExp().compile(/(\S*\s*=\s*)?_moz[^=>]*(=\s*[^>]*)?/gi),//strip _moz attributes 
     35/*01*/  new RegExp().compile(/(\s+)_moz[^=>]*=[^\s>]*/gi),//strip _moz attributes 
    3636/*02*/  new RegExp().compile(/\s*=\s*(([^'"][^>\s]*)([>\s])|"([^"]+)"|'([^']+)')/g),// find attributes 
    3737/*03*/  new RegExp().compile(/\/>/g),//strip singlet terminators 
    38 /*04*/ // new RegExp().compile(/<(br|hr|img|input|link|meta|param|embed)([^>]*)>/g),//terminate singlet tags 
    3938/*04*/  new RegExp().compile(/<(br|hr|img|input|link|meta|param|embed|area)((\s*\S*="[^"]*")*)>/g),//terminate singlet tags 
    4039/*05*/  new RegExp().compile(/(checked|compact|declare|defer|disabled|ismap|multiple|no(href|resize|shade|wrap)|readonly|selected)([\s>])/gi),//expand singlet attributes 
     
    4443/*09*/  new RegExp().compile(/\s+(\/)?>/g),//trim whitespace 
    4544/*10*/  new RegExp().compile(/\s{2,}/g),//trim extra whitespace 
    46 /*11*/  new RegExp().compile(/\s+([^=\s]+)(="[^"]+")/g),// lowercase attribute names 
    47 /*12*/  new RegExp().compile(/(\S*\s*=\s*)?contenteditable[^=>]*(=\s*[^>\s\/]*)?/gi),//strip contenteditable 
     45/*11*/  new RegExp().compile(/\s+([^=\s]+)((="[^"]+")|([\s>]))/g),// lowercase attribute names 
     46/*12*/  new RegExp().compile(/\s+contenteditable(=[^>\s\/]*)?/gi),//strip contenteditable 
    4847/*13*/  new RegExp().compile(/((href|src)=")([^\s]*)"/g), //find href and src for stripBaseHref() 
    4948/*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), 
    5049/*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 
    5150/*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 
     51/*17*/  new RegExp().compile(/<(td|th|li|option|br|hr|embed|param|pre|meta|link|title|area|input|textarea)[^>]*>/g),//singlet tag or output on 1 line 
    5352/*18*/  new RegExp().compile(/(^|<\/(pre|script)>)(\s|[^\s])*?(<(pre|script)[^>]*>|$)/g),//find content NOT inside pre and script tags 
    54 /*19*/  new RegExp().compile(/(<pre[^>]*>)(\s|[^\s])*?(<\/pre>)/g),//find content inside pre tags 
    55 /*20*/  new RegExp().compile(/(^|<!--(\s|\S)*?-->)((\s|\S)*?)(?=<!--(\s|\S)*?-->|$)/g),//find content NOT inside comments 
     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),//find content NOT inside comments 
    5655/*21*/  new RegExp().compile(/\S*=""/g), //find empty attributes 
    5756/*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 
     57/*23*/  new RegExp().compile(/(^|<\/script>)[\s\S]*?(<script[^>]*>|$)/g) //find content NOT inside script tags 
    5958]; 
    6059 
     
    10099        } 
    101100        s = s.replace(c[18], function(strn) { //skip pre and script tags 
    102           strn = strn.replace(c[20], function(st,$1,$2,$3) { //exclude comments 
    103                 string = $3.replace(/[\n\r]/gi, " ").replace(/\s+/gi," ").replace(c[14], function(str) { 
     101          strn = strn.replace(c[20], function(st,$1,$2) { //exclude comments 
     102                string = $2.replace(/[\n\r]/gi, " ").replace(/\s+/gi," ").replace(c[14], function(str) { 
    104103                        if (str.match(c[16])) { 
    105104                                var s = "\n" + HTMLArea.__sindent + str; 
Note: See TracChangeset for help on using the changeset viewer.