Jump to content

» «

Preserving all white spaces for CODE

No replies to this topic
  • Wesser

    The complexity simplifier, the efficiency optimizer

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown
  • Contribution Award [Mods]


Posted 02 October 2012 - 04:28 PM

Anyone may have noticed the first space character written at the beginning of every line gets trimmed for codes. It bothers a lot when copying a long code with original user's formatting and you must end up by quoting someone's post or editing your own, in order to view its source.

Adding white-space: pre-wrap; at #CODE into the CSS theme file will solve the issue. It works on FF but IE refuses such fix. It is due to the incomplete !DOCTYPE that GTAF uses, thus IE recognizes it as invalid. Using a proper !DOCTYPE means re-working on the style sheet again just for a little thing (it will fix other HTML/CSS issues aswell, though). Alternatively, considering that the CODE BB tag creates a two-lines table, one for displaying "CODE" and one for showing the code with id=CODE applied, I would suggest you to put the whole code within the <pre> HTML tag in the single cell of the second table line, by leaving the id=CODE attribute untouched. Do not forget to set margin: 0px to PRE in the CSS file.

Note: the last one is a cross browser solution. Then, you mustn't call the nl2br PHP function to convert new lines into <br> tags anymore, otherwise IE will collapse all consecutive line breaks. Both solution don't affect any visible modification to the forum's layout, it's 100% tested.

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users