Making code between < & > lower case?
Moderator: General Moderators
Making code between < & > lower case?
I got a WYSIWYG editor which puts most of the HTML code uppercase... Is there anyway to make everything betweend the < & > lower case and not effect the non HTML code?
Maybe even a HTML to XHTML convertor?
Thanks
Ben
Maybe even a HTML to XHTML convertor?
Thanks
Ben
Code: Select all
preg_replace('/<(.+?)>/ies','strtolower("\\1")',$text);Yep, thanks. It did the job however I had to change it to: strtolower("<\\1>") otherwise it remvoed the < & >.
Also, is it possible to put quotes into html? For exaample:
Would change to:
Thanks for your help!
Also, is it possible to put quotes into html? For exaample:
Code: Select all
<tabel border=0 height=100 width=300 cellpadding=4 cellspacing=1>Code: Select all
<tabel border="e;0"e; height="e;100"e; width="e;300"e; cellpadding="e;4"e; cellspacing="e;1"e;>Ahaha. Rather than change it to strtolower("<\\1>"), change the first bit to.. (plus I fixed it a bit)
my bad.
Ok, so to put quotes in... hmm... Assuming the param value is alphanumeric, then this might do the trick:
Code: Select all
preg_replace('/(<[^>]+>)/ies','strtolower("\\1")',$text);Ok, so to put quotes in... hmm... Assuming the param value is alphanumeric, then this might do the trick:
Code: Select all
preg_match_all('/<[^>]+>/is',$text,$matches);
$out = array();
for ($i=0; $i < count($matches[0]); $i++) {
$matches[0][$i] = preg_replace('/(\w+)=(\w+)/is','\\1="\\2"',$matches[0][$i]);
}Awesome works well... Thanks for your help on this. I really apprciate it
Just one hiccup though...
1. One tags such as alt=This is a picture it turns it into alt="This" is a picture
Hopefully this isn't to complicated...
Also how do I set it up so that it keeps the non html code in the text? I tried:
But it removed all the non html text.
Thanks again
1. One tags such as alt=This is a picture it turns it into alt="This" is a picture
Hopefully this isn't to complicated...
Also how do I set it up so that it keeps the non html code in the text? I tried:
Code: Select all
preg_match_all('/<ї^>]+>/is',$xhtml,$matches);
$out = array();
for ($i=0; $i < count($matchesї0]); $i++) {
$matchesї0]ї$i] = preg_replace('/(\w+)=(\w+)/is','\\1="e;\\2"e;',$matchesї0]ї$i]);
$final .= $matchesї0]ї$i];
}Thanks again
Last edited by Mr Tech on Wed May 18, 2005 11:30 pm, edited 1 time in total.
Silly me... I worked it out....
This is the code that ended up working
This is the code that ended up working
Code: Select all
preg_match_all('/<ї^>]+>/is',$text,$matches);
$out = array();
for ($i=0; $i < count($matchesї0]); $i++) {
$text .= preg_replace('/(\w+)=(\w+)/is','\\1="e;\\2"e;',$matchesї0]ї$i]);
}- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
you could make your life easier and check out some of the many editors that have been discussed here
viewtopic.php?t=6288&postdays=0&postorder=asc&start=0
viewtopic.php?t=6288&postdays=0&postorder=asc&start=0
I'm unable to switch editors for various reasons... I think I worked it out though... It seems stable enough...
Instead of searching for everything between the < & >, I just used this code:
The only problem is if someone enters something like red=color into the WYSIWYG editor it will put quotes around it but that's ok. I doubt anyone would need to do that...
Let me know if you think this code may not work for some cases...
Instead of searching for everything between the < & >, I just used this code:
Code: Select all
$xhtml =preg_replace('/(\w+)=(\w+)/is','\\1="\\2"',$xhtml);Let me know if you think this code may not work for some cases...
My advice is download htmltrim from http://www.w3.org and us it to tidy up your old code. htmltidy is another good piece of free software for tidying up your code.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
The code does not like something like
The colen (:) seems to stuff it up...
Any ideas on how to fix this? This is the code:
Code: Select all
<a href="e;http://www.google.com"e;>Any ideas on how to fix this? This is the code:
Code: Select all
$xhtml =preg_replace('/(\w+)=(\w+)/is','\\1="\\2"',$xhtml);