CODE blocks aren't monospace...

Status
Not open for further replies.

Gandalf007

Ars Tribunus Angusticlavius
6,975
Subscriptor
For me CODE blocks in posts show up in Helvetica/Arial, not Courier. Needless to say anything that is supposed to be formatted with spacing doesn't look right to me.

I checked this with Mozilla 0.96 (win2k and Linux), K-Meleon 0.6 (win2k), and Netscape 4.77 (Linux). All of these exhibit this behavior, so I don't think it's a browser bug, since Mozilla is a completely different codebase than NS4.

Yes, IE 5.5 shows it in Courier just fine. But I very rarely use IE in win2k, and obviously never in Linux, so I'd appreciate it if this could be fixed.

Thanks. :)
 

Gandalf007

Ars Tribunus Angusticlavius
6,975
Subscriptor
I took a look at the HTML source and found the problem.

The UBB "CODE" tag is transformed into:

[FONT=Arial, Helvetica]
code:[/FONT]

<hr>
Code:
<font face="Arial, Helvetica" size="2">
Whatever you wanted in the CODE block here....<P></font>
<hr>

Notice the EXTRA <font face="Arial"> tag inside the
Code:
 tags.  I've found the bug guys, now let's fix it!  View image: /infopop/emoticons/icon_smile.gif<P>I guess for some reason IE doesn't parse some tags inside <pre>...
blocks. This is not correct, which is why <, > still need to be escaped (which is currently handled by the UBB script, and why unwanted smilies can be thrown in). A better solution is to use
Code:
<CODE>...</CODE>
-- everything character inside <code> blocks is interpreted literally, including '<', but spacing isn't literal, hence the pre tag too.

BTW it also seems that the first set of font tags could be combined into one, but that's not a bug like the main issue.

Edit: Doh, forgot to disable HTML!
 

Gandalf007

Ars Tribunus Angusticlavius
6,975
Subscriptor
Code:
<CODE>for (int i=0; i<10; i++) {
    printf["%d", i);
}
</CODE>

<hr>
The preceding was done using
Code:
<code>....</code>
. Notice the '<' in the for expression, which is not escaped [I checked the source, since I posted this as "pure HTML" UBB didn't escape the '<', and it still displayed correctly. This is obviously a better solution than what is currently in place [even if it didn't have that extraneous <font> tag!)

BTW another bug is that when I went to edit this it replace the &lt; I had manually typed with "<". Also it would be nice if the Edit page remembered the status of the "Disable HTML" and "Pure HTML" checkboxes.

Boy I'm just full of bufixes. Are you guys hiring? ;)
 
Status
Not open for further replies.