Using the legend BBcode (And how to use it with titles starting on 0-9, A-F)

Status
Not open for further replies.

Cheesy

Gold Member
Joined
Jun 1, 2012
Messages
2,101
Likes
157
IG Name
Brian Johnsson
#1
A lot of people seem to be struggling with the legend bbcode. This tag has been around for a couple of years, but it's somewhat buggy and weird to use and a lot of people are therefore discouraged from using it.

With this post I hope to show you how to avoid the following situations:

[legend=#499499Example]#e0efffThis is an example of a "bugged" legend.[/legend]
[legend=#499499Example]#e0efffAhis is an example of an even more "bugged" legend.[/legend]
[legend=#499499|Example]#e0efff|This is an example of a bad fix for the "bugged" legend above.[/legend]

And instead make it look like it's "supposed" to look:

[legend=#499499 Example ]#e0efff
This is an example of a better fix for the "bugged" legend above.[/legend]

The fix I've come up with for the legend tag can be broken down into two steps:

  • Fix the issue when attempting to use titles starting on the character 0-9 and A-F (Characters used in hexadecimal color coding)
  • Fix the issue with the first character after a color code disappearing
All whilst avoiding to use visible dummy characters like "|" or "•".

We'll start off by fixing the legend title. Nearly all the posts using legends on this forum contain dummy characters to break the color code up from the rest of the legend tag. This causes the legend to look like the third example up above. My proposed fix for this is to use invisible characters to do more or less the same thing, but without leaving any visible evidence of a fix.

There's multiple invisible characters you can use, but the easiest character to use that leaves near no evidence of existing is a non-breaking space " ". This character looks exactly like a normal space, but forces the page to treat it like a "normal" character. For us this means that it won't be removed like all other excess spaces are when posting, but will continue to exist. By typing a non-breaking space on each side of the title you will break the title from the color code whilst keeping it in the center of the title box. This leaves us with the following bbcode code:

Code:
[legend=#499499 Example ]
You can type a non-breaking space on a windows system by holding down your Alt key and typing "0160" on the numpad. (Sometimes AltGr instead of Alt). Note that you can not always copy a non-breaking space and have it stay that way. Sometimes it will convert into a regular breaking space.

The next fix is for the body color of the legend. You can usually fix this too by entering a non-breaking space, but this will leave the first row slightly indented. Instead, we'll use a dummy bbcode tag to break away from the color code. What tag you use doesn't really matter since it's instantly closed, I use the center tag for good measure.

Code:
[legend=#499499 Example ]#e0efff[center][/center]
We can now type our content as regular. If we add additional spaces or line breaks after our dummy tag, it will be contracted and removed when you post. The result is a legend tag looking like the fourth example. This leaves us with a final legend bbcode format looking like this:

Code:
[legend=*Title color* Example ]*Body color*[center][/center]*Content*[/legend]
You can use regular preset colors (red, blue, green, lightblue, darkred, etc) instead of hexadecimal codes as well. Remember that copying non-breaking spaces doesn't always work - instead - try to directly input it with the Alt-code, it is also available in the windows character map. If you use another OS you're on your own. :wavebye:
 

Ray_P

Bronze Member
Joined
Jul 10, 2011
Messages
368
Likes
33
IG Name
卐 卐 卐 卐
IG Faction
卍 卍 卍 卍
#3
This is really useful. Thanks mate!
 
Joined
Apr 14, 2010
Messages
11,754
Likes
2,463
IG Name
they want my full name
IG Faction
i told em rockstar
#4
useful, could never be bothered to actually try to fix that issue lo
 
Status
Not open for further replies.