php forum
php mysql forum
php mysql smarty
 
Page 1 of 2 1 2 >
Topic Options
#222601 - 08/19/02 06:04 PM </font color>
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA

   </font color> to Del.icio.us Add to del.icio.us
  Digg </font color> Digg it
The color markup tag translates its closing tag to </font color>. Is this standards-compliant?
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222602 - 08/19/02 06:13 PM Re: </font color> [Re: joeuser]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25432
Loc: Texas
I don't think so... would need to do a test page and check <img src="/forum/images/icons/smile.gif" alt="" /><br /><br />uno momento por favor
_________________________
- Allen wavey
- What Drives You?

Top
#222603 - 08/19/02 06:15 PM Re: </font color> [Re: SurfMinister]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25432
Loc: Texas
No, it isn't:<br /><br />http://validator.w3.org/check?uri=http%3....0+Transitional<br /><br />needs to be plain </font>
_________________________
- Allen wavey
- What Drives You?

Top
#222604 - 08/19/02 06:19 PM Re: </font color> [Re: SurfMinister]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
So should that be considered a bug?
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222605 - 08/19/02 06:21 PM Re: </font color> [Re: joeuser]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25432
Loc: Texas
technically yes, as the current closing tag really isn't compliant to any html standard <img src="/forum/images/icons/wink.gif" alt="" />
_________________________
- Allen wavey
- What Drives You?

Top
#222606 - 08/19/02 06:33 PM Re: </font color> [Re: SurfMinister]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
Thanks <img src="/forum/images/icons/smile.gif" alt="" />
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222607 - 08/19/02 06:38 PM Re: </font color> [Re: joeuser]
JustDave Offline
That 70's Guy

Registered: 06/24/01
Posts: 4097
<blockquote><font class="small">posted by Dave_L:</font><hr /> So should that be considered a bug? <hr /></blockquote><br /><br /><br />Actually that's a "designed flaw"... lol This was the way Rick was able to deal with the new color markup code.<br /><br />Perhaps one can still simply replace the </font color> tags with </font> tags before displaying so that they are compliant?
_________________________
~Dave
ChattersOnline.com

Top
#222608 - 08/19/02 06:44 PM Re: </font color> [Re: sjsaunders]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
That sounds like it would work, except that the translation would have to be done every time a post is displayed, which seems inefficient.<br /><br />A couple of other choices:<br /><br />Use the method employed by UBB.classic, where the opening and closing tags are translated with a single regex.<br /><br />Use <!--color--></font> in place of </font color>. I haven't thought this through, so I'm not sure if it would work.
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222609 - 08/19/02 06:46 PM Re: </font color> [Re: sjsaunders]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
[]<br />Actually that's a "designed flaw"... lol This was the way Rick was able to deal with the new color markup code.<br /><br />Perhaps one can still simply replace the </font color> tags with </font> tags before displaying so that they are compliant? <hr /></blockquote><br /><br />Yes, it should be possible. I've been thinking of adding this to the markuphack since there are even more tags that aren't really xhtml compliant in the same way.
_________________________
/Gardener | Complete list of my mods

Top
#222610 - 08/19/02 06:50 PM Re: </font color> [Re: c0bra]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25432
Loc: Texas
why wouldn't a plain </font> work? You are only closing the opening <font color= tag
_________________________
- Allen wavey
- What Drives You?

Top
#222611 - 08/19/02 06:56 PM Re: </font color> [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
That sounds like a better idea to have the html comment in front of the closing font tag, and I don't see why it shouldn't work.
_________________________
/Gardener | Complete list of my mods

Top
#222612 - 08/19/02 06:58 PM Re: </font color> [Re: SurfMinister]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
I don't think that would work, because there may be other </font> tags that don't correspond to the color markups. (Unless the UBB.classic method were used.)
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222613 - 08/19/02 07:00 PM Re: </font color> [Re: SurfMinister]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Other markup tags also have the </font> tag so the undo_markup function won't be able to distinguish which one is used for the color tag.
_________________________
/Gardener | Complete list of my mods

Top
#222614 - 08/21/02 03:53 AM Re: </font color> [Re: c0bra]
mod_perl Offline
Newbie

Registered: 08/15/02
Posts: 16
<blockquote><font class="small">posted by Gardener:</font><hr /> Other markup tags also have the </font> tag so the undo_markup function won't be able to distinguish which one is used for the color tag.<hr /></blockquote> <br /> <br />undo_markup could easily tell which closing font tags are used for color tags because they are the ones that follow a font tag with a <br />color attribute. I haven't seen the latest markup code but this is the way to do it (with perl): <br /> <br /><pre><font class="small">code:</font><hr> <br />$Body =~ s/\[$lang{'COLOR_RED'}\](.*?)\[\/$lang{'COLOR_RED'}\]/<font color=red>$1<\/font>/ig; # do <br />$Body =~ s/<font color=red>(.*?)<\/font>/\[$lang{'COLOR_RED'}\]$1\[\/$lang{'COLOR_RED'}\]/ig; # undo <br /></pre><hr> <br />

Top
#222615 - 08/21/02 09:22 AM Re: </font color> [Re: jjski]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Won't work.<br /><br />Well, it will, but start nesting tags and it will break. That's the reason the start and end font tag is replaced separately and the reason that the </font> has the extra info so that it differs from other </font> tags.
_________________________
/Gardener | Complete list of my mods

Top
#222616 - 08/21/02 10:21 AM Re: </font color> [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
Actually, mod_perl's post describes the method used by UBB.classic that I referred to earlier. Nested tags are handled properly if you loop over the regex replacement operations. Each loop iteration handles one layer of nesting.
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222617 - 08/21/02 10:52 AM Re: </font color> [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Granted, with added code, the code would work. =] Sort of, at least. There would still be problems with extra tags inside the color tag that would also use the </font> right? Because that would match first.
_________________________
/Gardener | Complete list of my mods

Top
#222618 - 08/21/02 11:01 AM Re: </font color> [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
I'm not sure what you mean. Could you provide an example?
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222619 - 08/21/02 11:41 AM Re: </font color> [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
More tags than the color-tag could generate the &lt;/font&gt; end tag, and when parsing the color tag those tags would match as well.<br /><br />If these tags were used:<br />[font:courier] [color:red] [size:5] Red courier, size 5 [/size] [/color] [/font]<br /><br />And it would create the following html:<br />&lt;font style="courier"&gt;&lt;font color="red"&gt;&lt;font size="5"&gt; Red courier, size 5 &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;<br /><br />Then the regexp would parse the code like this:<br />[font:courier][color:red][size:5] Red courier, size 5 [/font][/color][/size]<br /><br />Because the regex would match the first occurance of &lt;/font&gt;. In the above example, the tags are just nested wrong, but it could match other code which would break things even worse. Like &lt;/font&gt; which is inside the quote-tag if I'm not mistaken.
_________________________
/Gardener | Complete list of my mods

Top
#222620 - 08/21/02 12:24 PM Re: </font color> [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
That wouldn't happen.<br /><br />The code I use in my font hack for UBB.classic looks like this:<br /><br />my $match = 1;<br />while($match != 0) {<br /> $match = 0;<br /> $match++ if $text =~ s~(<font (.+?)>)(.+?)(</font>)~\[font $2\]$3\[/font\]~is;<br />}<br /><br />Here's how it works:<br /><br />Initially: <font style="courier"><font color="red"><font size="5"> Red courier, size 5 </font></font></font><br /><br />After iteration 1: <font style="courier"><font color="red">[font size="5"] Red courier, size 5 [/font]</font></font><br /><br />After iteration 2: <font style="courier">[font color="red"][font size="5"] Red courier, size 5 [/font][/font]</font><br /><br />After iteration 3: [font style="courier"][font color="red"][font size="5"] Red courier, size 5 [/font][/font][/font]
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222621 - 08/21/02 02:38 PM Re: </font color> [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
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.
_________________________
/Gardener | Complete list of my mods

Top
#222622 - 08/21/02 02:57 PM Re: </font color> [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
Hmmmmmm, you're right, that code does behave as you describe.<br /><br />I did some fairly complex tests for that hack, and couldn't break it, but maybe I didn't find the right test case.
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222623 - 08/21/02 03:15 PM Re: </font color> [Re: joeuser]
JustDave Offline
That 70's Guy

Registered: 06/24/01
Posts: 4097
Pages that display posts, such as showflat.php could have the </font color> tag converted to </font> to remain standards compliant.<br /><br />Just prior to this:<br /><br />$postrow[$i]['Body'] = $Body;<br /><br />You could use this:<br /><br />$Body = str_replace("</font color>","</font>",$Body);<br /><br />Then the browser would recieve compliant code for viewing and custom tags could remain for editing and other such purposes.<br /><br /><br />Am I missing something with all of this? I think I'm understanding that the main goal is to have the html that is displayed be standards compliant. How the html is handled on the backend prior to display shouldn't make a difference. (IMHO) <img src="/forum/images/icons/smile.gif" alt="" />
_________________________
~Dave
ChattersOnline.com

Top
#222624 - 08/21/02 03:32 PM Re: </font color> [Re: sjsaunders]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
I'd prefer to use <!--color--></font> instead of </font color>. I think it's simpler to make the posts that are stored in the database correct HTML. Then you don't have to worry about special conversions whenever you want to display them.
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222625 - 08/21/02 03:33 PM Re: </font color> [Re: sjsaunders]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
That's what we've all said as well, but then we went on about discussing if we could have the non-compliant html removed completely.<br /><br />It would be nice to not have to do that extra replace for the color tag (and the others that I have in the markuphack), but it works.
_________________________
/Gardener | Complete list of my mods

Top
#222626 - 08/21/02 03:55 PM Re: </font color> [Re: joeuser]
Gardener Offline
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.
_________________________
/Gardener | Complete list of my mods

Top
#222627 - 08/21/02 04:13 PM Re: </font color> [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
Not meaning to be too picky, but before this gets "standardized", do you think <!--color--> (no spaces) would be better than <!-- color -->? <img src="/forum/images/icons/smile.gif" alt="" />
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#222628 - 08/21/02 05:01 PM Re: </font color> [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Don't know, I always have a space before/after the --, I think some ancient browser broke if this wasn't the case. Not sure though, but I just do it by habit, removing the spaces should probably be OK and might be better for the parsing.<br /><br />Also, only the code in the undo_markup should be added instead of replaced. Thus making sure that old posts are editable (is that a word? =]), but all new posts use the new markup.
_________________________
/Gardener | Complete list of my mods

Top
#222629 - 08/22/02 03:20 PM Re: </font color> [Re: c0bra]
mod_perl Offline
Newbie

Registered: 08/15/02
Posts: 16
I don't mind being wrong when it sparks such a useful discussion. <img src="/forum/images/icons/wink.gif" alt="" /> <br /> <br />I solved this problem by disabling color markup since it clashes with stylesheets, and discourages those who like to distinguish themselves by posting in all violet text. Crude but effective.

Top
#222630 - 08/22/02 04:59 PM Re: </font color> [Re: jjski]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
That's one way of fixing the problem of course. =] If my users would start setting the color of all the text in their posts and change font styles etc I would definetely remove the function. But at the moment it's only used in signatures, or to highlight some small bits of text. But before I'd remove it completely I'd try to convince users that are overusing those markups to stop.
_________________________
/Gardener | Complete list of my mods

Top
Page 1 of 2 1 2 >