Hello everybody.
Been trying to solve this for a couple of days now and just hitting a dead end. I have a WYSIWYG editor on a admin panel in replacement for a textarea box. This is all fine, except my client wants valid XHTML, but the editor produces HTML.
So instead of <br /> it produces <br>, etc.....
I have created regular expressions using preg_replace to replace things like this but I'm having trouble with this line:
$text = preg_replace('/(<img .*?)("|\'| )>/i','\1\2 />',$text);
The problem
Now, it replaces <img> tags fine, so that <img src='....' title='....' alt='....'> is converted to <img ........ /> and that is all OK. The problem is that for some reason it also changes <a href='.....'> to <a href='........' /> and I'm not sure why.
Solution
Can someone either suggest a solution to this regular expression, or perhaps a extention or module that is easy to implement that converts HTML to XHTML.
Thank you.