 |
 |
 |
 |
#222621 - 08/21/02 02:38 PM
Re: </font color>
[Re: joeuser]
|
Addict
Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Add to del.icio.us
Digg it
|
I still can't see how the regex can now which font closing tag it should parse? <br /><br />Maybe my example was a bad one, since you could merge them into one markup tag like you have. But that wasn't the point. The point being that if different markups both have the </font> the regex will have no way of knowing which one is the one that it should match to. Some amazing things can be done with regexes, but magic isn't one of them. =]<br /><br />Testing your code shows that the following happens:<br />Initially:<br /><font style="courier"><font color="red"><font size="5"> Red courier, size 5 </font></font></font><br /><br />After iteration 1: <br />[font style="courier"]<font color="red"><font size="5"> Red courier, size 5 [/font]</font></font><br /><br />After iteration 2: <br />[font style="courier"][font color="red"]<font size="5"> Red courier, size 5 [/font][/font]</font><br /><br />After iteration 3: <br />[font style="courier"][font color="red"][font size="5"] Red courier, size 5 [/font][/font][/font]<br /><br />In this case it doesn't matter that much of course, but it shows that the replace is done with the first possible match. If the </font> tag is part of something else, it will break, and it could potentially screw up the nesting as well.
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#222626 - 08/21/02 03:55 PM
Re: </font color>
[Re: joeuser]
|
Addict
Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
|
True, it would be nice if the correct html was in the database as well. And the html comment should work perfectly OK.<br /><br />Here's the code for this if anyone wants it, do the following in ubbt.inc.php:<br />Find this line:<br /><pre><font class="small">code:</font><hr><br /> $matches[0][$i] = preg_replace("/\[\/{$ubbt_lang['COLOR']}\]/","</font color>",$matches[0][$i]);<br /></pre><hr><br />Change it to this:<br /><pre><font class="small">code:</font><hr><br /> $matches[0][$i] = preg_replace("/\[\/{$ubbt_lang['COLOR']}\]/","<!-- color --></font>",$matches[0][$i]);<br /></pre><hr><br />Find this line:<br /><pre><font class="small">code:</font><hr><br /> $Body = preg_replace("/\[\/{$ubbt_lang['COLOR']}\]/","</font color>",$Body);<br /></pre><hr><br />Change it to this:<br /><pre><font class="small">code:</font><hr><br /> $Body = preg_replace("/\[\/{$ubbt_lang['COLOR']}\]/","<!-- color --></font>",$Body);<br /></pre><hr><br />Find this line:<br /><pre><font class="small">code:</font><hr><br /> $Body = preg_replace("/<\/font color>/i","[/{$ubbt_lang['COLOR']}]",$Body);<br /></pre><hr><br />And change it to this:<br /><pre><font class="small">code:</font><hr><br /> $Body = preg_replace("/<!-- color --><\/font>/i","[/{$ubbt_lang['COLOR']}]",$Body);<br /></pre><hr><br /><br />But after this is done, the color markup won't be parsed correctly when changing posts done with the old way. But I guess it should work by adding the given lines instead of replacing the old line, that way even old posts should be parsed correctly during editing. Haven't tested it though.
|
|
Top
|
|
|
|
 |
 |
 |
 |
|
|