And here is the second part:
    //clean up H tags   
    html = html.replace( /<H1([^>]*)>/gi, '<H1>' ) ;
    html = html.replace( /<H2([^>]*)>/gi, '<H2>' ) ;
    html = html.replace( /<H3([^>]*)>/gi, '<H3>' ) ;
    html = html.replace( /<H4([^>]*)>/gi, '<H4>' ) ;
    html = html.replace( /<H5([^>]*)>/gi, '<H5>' ) ;
    html = html.replace( /<H6([^>]*)>/gi, '<H6>' ) ;
    html = html.replace( /<P([^>]*)>/gi,  '<P>' ) ;
    html = html.replace( /<BR([^>]*)>/gi, '<BR>' ) ;
    html = html.replace( /<P>\s*(<P>)+<\/P>/gi,   '<P>' ) ;
    html = html.replace( /<\/P>\s*(<\/P>)+<\/P>/gi, '</P>' ) ;
   
    html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;

    // no comment...
    html = html.replace( /<!--[\s\S]*?-->/gi, '' ) ;
   
    // transform bullet lists
    var re = new RegExp("<P>·<SPAN>(&nbsp;| )*</SPAN>([\\s\\S]*?)</P>", 
"gi");
    html = html.replace( re, "<LI>$2</LI>" ) ;
    re = new RegExp("<P>·(&nbsp;| )*([\\s\\S]*?)</P>", "gi");
    html = html.replace( /(<BR>|<P>)[§·-](&nbsp;| )*([\s\S]*?)<\/P>/gi, 
"<LI>$2</LI>" ) ;
    // remove spaces at begining
    html = html.replace( /^(&nbsp;| )*\s*/, '') ;
    // replace all stupid <P align=center>...</P> because they are 
overridden by higher
    // style declarations like justify, etc.
    html = html.replace( /<P\s*align=center>([\s\S]*?)<\/P>/gi, 
'<BR><CENTER>$1</CENTER>' ) ;
    // remove useless </CENTER><CENTER>
    html = html.replace( /<\/CENTER>(\s*<BR>\s*)<CENTER>/gi, '$1' ) ;
    // remove useless <BR> in <TD>
    html = html.replace( /(<TD[^>]*>)\s*<BR>\s*/gi, '$1' ) ;
    // remove useless <A name=...></A>
    html = html.replace( /<A\s+name=[^>]+><\/A>/gi, '' ) ;
    // replace <CENTER>...</CENTER> inside of TDs
    html = html.replace( 
/(<TD[^>]*)>\s*<CENTER>([\s\S]*?)<\/CENTER>\s*<\/TD>/gi,
        '$1 align=center>$2</TD>' ) ;
    // remove Paragraphs inside TD
    html = 
html.replace(/(<TD[^>]*>)\s*<P[^>]*>([\s\S]*?)\s*<\/P>\s*([\s\S]*?<\/TD>)/gi, 

        '$1$2$3');
    // prepare to initilize tables
    html = html.replace( /<TABLE/gi, '<TABLE ID="new_table"');
    // Remplacer <TD...></TD> par <TD>&nbsp;</TD>
    html = html.replace( /(<TD([^>]*)>)\s*<\/TD>/gi, '$1&nbsp;</TD>') ;
    // Remove empty tags (three times, just to be sure SAUF <TD></TD>).
    html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
    html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
    html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
    html = html.replace( /[^\n\r]<P>/gi, '<P>' ) ;
    html = html.replace( /[^\n\r]<BR>/gi, '<BR>' ) ;
  // supprimer les largeurs des tables
    html = html.replace( 
/(<table.+)width\s*=s*[\"\']?[0-9]+%?[\"\']?/gi, '&1' ) ;
 

    //alert(html)
  return (html);
    }


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317094
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to