nice one.  I've been extending your CleanMSText custom tag a little bit,
e.g. replacing the deprecated <u> with the equivalent in CSS, and a few
extra MS Word nonsense html tags you'd missed out.  Still want to do more
on this, e.g. replacing all use of <font> tags, but that'll be more work to
parse it.




                                                                                       
                            
                    "Chris                                                             
                            
                    Tazewell"            To:     <[EMAIL PROTECTED]>                   
                  
                    <[EMAIL PROTECTED]        cc:                                      
                                 
                    ll.co.uk>            Subject:     [ cf-dev ] WYSIWYG editors - 
XHTML validation                
                                                                                       
                            
                    27/07/2004                                                         
                            
                    10:14                                                              
                            
                    Please                                                             
                            
                    respond to                                                         
                            
                    dev                                                                
                            
                                                                                       
                            
                                                                                       
                            



I know some people on this list have mentioned the need for XHTML valid
code from WYSIWYG editors like SoEditor and Activedit... usually for
government contracts etc.

Obviously it's damn near impossible to find anything on the MM exchange,
which in some respects is a blessing, since there's quite a lot of crap on
there anyway. If you still need this, I've written a fairly basic UDF which
runs through the tags and sets all the non-quoted code to lower case. This
is the first version of the function, so there may be bugs etc.

Feel free to use it, or hack it to pieces. But if you do make any
modifications or find bugs, let me know what they are and I'll add them to
the pot.

Cheers
Taz



<cfscript>
 // ***************
 // ValidXHTML - Written By Taz on the back of a beer mat
 // Parses html input from a WYSIWYG editor and validates as xhtml
(lowercase tags)
 // Note: tag attribute values must be in double quotes
 // Use it as much as you like, but let me know if you find any bugs or add

 //  functionality via the contact form on www.tazmedia.co.uk
 // ***************

 function ValidXHTML(myString) {
  // initialise the start tag index
  startIndex = 1;

  while (startIndex LTE Len(myString)) {
   // get the index of the next tag opening and closing angle bracket
   openTag = Find("<", myString, startIndex);
   closeTag = Find(">", myString, openTag) + 1;
   // grab that tag
   myTag = Mid(myString, openTag, closeTag-openTag);

   // if there are upper case letters, process case converter
   if (REFind("[A-Z]", MyTag, 1)) {
    // initialise start sub tag index
    startSubIndex = 1;
    myLCaseTag = myTag;

    while (startSubIndex LT Len(myLCaseTag)) {
     if (Find('"', myLCaseTag, startSubIndex)) {
      endSubindex = Find('"', myLCaseTag, startSubIndex);
      // grab start, current part and end as individual sub strings
      if (startSubIndex GT 1) {
       tagHead = Left(myLCaseTag, startSubIndex-1);
      } else {
       tagHead = "";
      }
      mySubStr = Mid(myLCaseTag, startSubIndex, endSubIndex-startSubIndex);

      tagTail = Right(myLCaseTag, Len(myLCaseTag)-endSubindex + 1);

      // rebuild the tag with lowercase letters
      myLCaseTag = tagHead&LCase(mySubStr)&tagTail;
      startSubIndex = Find('"', myTag, endSubIndex+1) + 1;
     } else {
      myLCaseTag = LCase(myTag);
      startSubIndex = Len(myLCaseTag) + 1;
     }
    }
    // Now replace all instances of this tag in the string
    myString = Replace(myString, myTag, myLCaseTag, 'all');
   }
   // Set start index past current tag
   startIndex = closeTag;
  }
  return myString;
 }
</cfscript>




-- 
These lists are syncronised with the CFDeveloper forum at 
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
 
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by 
activepdf.com*
      *Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
           *Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*

To unsubscribe, e-mail: [EMAIL PROTECTED]

Reply via email to