PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Nov 20, 2019 11:41 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed May 18, 2005 7:54 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 8:02 pm 
Offline
Forum Regular
User avatar

Joined: Sat Mar 12, 2005 8:13 pm
Posts: 703
Location: US
Syntax: [ Download ] [ Hide ]
preg_replace('/<(.+?)>/ies','strtolower("\\1")',$text);


I'm pretty sure that'll do it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 8:42 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 9:22 pm 
Offline
Forum Regular
User avatar

Joined: Sat Mar 12, 2005 8:13 pm
Posts: 703
Location: US
Ahaha. Rather than change it to strtolower("&lt;\\1&gt;"), change the first bit to.. (plus I fixed it a bit)
Syntax: [ Download ] [ Hide ]
preg_replace('/(<[^>]+>)/ies','strtolower("\\1")',$text);

my bad.

Ok, so to put quotes in... hmm... Assuming the param value is alphanumeric, then this might do the trick:

Syntax: [ Download ] [ Hide ]
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]);

}


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 9:46 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424


Last edited by Mr Tech on Wed May 18, 2005 11:30 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 11:15 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 11:38 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 12:26 am 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424
ARGHHH!!! For some reaosn the code is no longer working... Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 9:55 am 
Offline
DevNet Resident
User avatar

Joined: Fri Dec 24, 2004 3:59 am
Posts: 1452
Location: Lucknow, UP, India
It might be easier to search around for option that will make it write tags in lowercase.
Hmmm... i have a premonition.. are you using MS-Frontpage :?: then, buddy, there is the option to make it write tags in lowercase :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 4:47 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424
Nah an online WYSIWYG editor called htmlarea... It's no longer developed and I can't find any options to make it lower case or put quotes around code in the source code... This script was working before but has all of a sudden stopped working... I might have chnaged the code without knowing...


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 10:10 am 
Offline
DevNet Resident
User avatar

Joined: Wed Oct 09, 2002 6:51 pm
Posts: 1206
Location: Keele, U.K.
you could make your life easier and check out some of the many editors that have been discussed here


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2005 6:42 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424
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 &lt; &amp; &gt;, I just used this code:

Syntax: [ Download ] [ Hide ]
$xhtml =preg_replace('/(\w+)=(\w+)/is','\\1="\\2"',$xhtml);


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...


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2005 6:58 pm 
Offline
Forum Regular
User avatar

Joined: Wed May 11, 2005 2:33 am
Posts: 509
Location: Alicante (Spain)


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2005 7:30 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
:arrow: Moved to regex


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 7:03 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Aug 10, 2004 3:08 am
Posts: 424


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group