|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Replacing class styles
I'm using the script below to parse out a variable and replace the class tag with class="link12" whenever there is an <a href tage which works fine. However, our users copy and paste from MS Word into our editor which grabs the extraneous word styles. So now my code changes all the word class tag too which I don't want. For instance if theres a tag <p class="MsoBodyText"> it changes it to <p class="link12"> which I don't want. I know it's a small change but I'm not sure what to do. Normally I would just strip the word styles out completely but I've been told to leave them in. Any help would be appreciated.
<cfset aLinks = ListToArray(ReplaceNoCase(stObject.content1,"<a","#Chr(167)#<a","ALL"),Chr(167))> <cfloop index="a" from="1" to="#ArrayLen(aLinks)#"> <cfif not FindNoCase("class=#chr(34)#",aLinks[a],1)> <cfset aLinks[a] = ReplaceNoCase(aLinks[a], "<a", "<a class=#chr(34)#link12#chr(34)#")> <cfelseif FindNoCase("class=#chr(34)#",aLinks[a],1)> <cfset class = Mid(aLinks[a], FindNoCase("class=#chr(34)#",aLinks[a],1)+7, Len(aLinks[a]))> <cfset class = Left(class, Find(chr(34), class, 1)-1)> <cfset aLinks[a] = ReplaceNoCase(aLinks[a], class, "link12", "All")> </cfif> </cfloop> <!---<cfset temp = ArrayDeleteAt(aLinks, 1)>---> <cfset stObject.content1 = ArrayToList(aLinks, chr(10))>
__________________
http://www.dieselstudios.com - http://www.trackmycash.com - http://www.hamptonsoftrentdale.com |
|
#2
|
|||
|
|||
|
Is there anything to differentiate the Word styles from the other types of styles? If there isn't, I don't think what you are asking for is possible.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Quote:
Unfortunately I don't think so. At this point with this job I'm about the throw in the towel. |
|
#4
|
|||
|
|||
|
Sometimes part of being a good developer is the ability to clearly explain why something that someone is asking for is simply not feasable. Technically, anything is possible, but the cost/benefit ratio must be considered and sometimes the payoff just isn't worth the effort, not matter how much the requestor wants it. I think your best option is to try to get this message across.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Replacing class styles |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|