|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Need to edit html dynamically
I need a script that will step through an cfml document and remove html. For example, if it comes upon this:
<p style='margin:0in;margin-bottom:.0001pt'> it will replace it simply with a paragraph tag, <p> We have a lot of people saving Word files as html and as most of you know it puts a ton of code in that's not necessary. The easy solution would be to tell them not to do that but they are the least technical people so this is all new to them. I have looked high and low for a script, plus tried a few things but still haven't had any luck.
__________________
http://www.dieselstudios.com - http://www.trackmycash.com - http://www.hamptonsoftrentdale.com |
|
#2
|
|||
|
|||
|
Is it always a paragraph tag that you want to replace, or are there other tags? How is the script supposed to know what to replace the original code with...is it always just "if you run into <br px:93093 blah blah blah> then replace it with <br>"? Or will there be rules associated with what gets replaced and what should be substituted?
|
|
#3
|
|||
|
|||
|
There will be other tags too. I just used the paragraph tag as an example. It will be, if you run into this, replace it with this.
|
|
#4
|
|||
|
|||
|
You'll want to use a set of regular expressions then. Something like this:
<cfsavecontent variable="originalText"> <br px:foo blah blah......~~~~~ bar> normal text with nothing wierd. normal <p> tag Bad paragraph tag: <p style='margin:0in;margin-bottom:.0001pt'> </cfsavecontent> <cfset newText = reReplaceNoCase( originalText, '<br[^>]+>', '<br>', 'All' ) /> <cfset newText = reReplaceNoCase( newText, '<p[^>]+>', '<p>', 'All' ) /> <cfoutput>#htmlCodeFormat( newText )#</cfoutput> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Need to edit html dynamically |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|