This section describes general rules of BB-code 2.0.
Those rules are not directly related to most common use of KBB, which is KBB-to-HTML. Those are generic rules for any KBB application.
It's just made of:
Usually BB tag accepts a single setting as a pair of key and value. For example: key may be "theColor" and the value may be "red".
So the example tag "myColor" with a setting "theColor" set to "red" looks like that:
Also simple parameters, with no value attached are correct. Like this:
But there are also more complicated tags, which have 2 parts: opening part and closing part.
The good example of open-close tag is tag to make bold text. We use [b] tag for that. We need to say where to start bold text and where the bold text ends. We do it this way:
So this BB-Code:
This is a bold word and this is italic word and this is underline
This is bold and underlined text
In old-school BB-Code you need to ensure the closings are in opposite order than openings.
So this would be illegal in old BB: [b][u][/b][/u] - because there is: open b, open u and then close b. And you can't close b because there is still u opened. This means that generated HTML will be invalid.
However in KemuBB it is correct to do it as KemuBB will close and reopen html tags in proper order automagically.
There are some tags that are not auto-closable for different reasons. Look intto "tag list" chapter for further reference.
No white-char is allowed, no non-ASCII characters allowed, only simple letters and ciphers.
So this is legal:
So for example, putting url to image should be always with "" or '':
For example, to pass a text abc'd as a parameter you can do:
Those rules are not directly related to most common use of KBB, which is KBB-to-HTML. Those are generic rules for any KBB application.
Simple BB tag
The simple BB Tag looks like this:ⓘ Example usage:
[myTag]
It's just made of:
- a [ character - which opens a tag,
- then name of a tag (this will be "myTag" in this case)
- and then ] character - which closes a tag,
Escaping
As you can see, the [ character is always opening a tag. In case you want to render [ as normal character (escape), just write two of them, like this: [[Parameters
In some BB tags you can define additional settings. For example set a color or define path to image file.Usually BB tag accepts a single setting as a pair of key and value. For example: key may be "theColor" and the value may be "red".
So the example tag "myColor" with a setting "theColor" set to "red" looks like that:
ⓘ Example usage:
[myColor theColor=red]
Also simple parameters, with no value attached are correct. Like this:
ⓘ Example usage:
[theTag paramA]
More parameters
If you need to pass more parameters, just put them one after another, separating with space like this:ⓘ Example usage:
[myColor theColor=red theBackground=green theNumber=3]
Tag open-close rules
We discussed simple tags, which just have a name and some parameters. Those tags don't open anything, so they don't have to be closed.But there are also more complicated tags, which have 2 parts: opening part and closing part.
The good example of open-close tag is tag to make bold text. We use [b] tag for that. We need to say where to start bold text and where the bold text ends. We do it this way:
ⓘ Example usage:
[b]bold[/b]
So this BB-Code:
ⓘ Example usage:
looks like this after rendering to html:This is a [b]bold word[/b] and this is [i]italic word[/i] and this is [u]underline[/u]
This is a bold word and this is italic word and this is underline
Open, open, close, close
You can put one open-close tag "inside" of another like this:ⓘ Example usage:
which will emit this:This is [b]bold and [u]underlined text[/u][/b]
This is bold and underlined text
In old-school BB-Code you need to ensure the closings are in opposite order than openings.
So this would be illegal in old BB: [b][u][/b][/u] - because there is: open b, open u and then close b. And you can't close b because there is still u opened. This means that generated HTML will be invalid.
However in KemuBB it is correct to do it as KemuBB will close and reopen html tags in proper order automagically.
Closing tag autodetection
Also in Kemu-BB most of the tags are auto-closable. It means you don't need to worry of closing tags in proper order. Instead of:ⓘ Example usage:
you can use [/] - as auto-close:[b][u]The bold and underlined[/u][/b]
ⓘ Example usage:
So the tag [/] will just try to guess which tag needs to be closed - and closes it. But remember - it closes just ONE tag.[b][u]The bold and underlined[/][/]
There are some tags that are not auto-closable for different reasons. Look intto "tag list" chapter for further reference.
Parameters formatting
The tag, the key and the value must contain only a-z, A-Z, 0-9 and _ characters (so only letters, ciphers and _).No white-char is allowed, no non-ASCII characters allowed, only simple letters and ciphers.
So this is legal:
ⓘ Example usage:
but this is not (because of spaces !):[the_VeryLong_Name_Of_a_tag andVeryStrange___andLOngParameterKey=longValue aNumber=2]
ⓘ Example usage:
[the VeryLong Name_Of_a_tag andVeryStrange__ andLOngParameterKey=longValue]
Putting text to parameter
If you need to pass a text as a value of parameter, which contains spaces or disallowed characters, do it this way:ⓘ Example usage:
You can use use single quotation or double quotation - whatever you prefer.[theTag theKey="The long text which is a value"]
So for example, putting url to image should be always with "" or '':
ⓘ Example usage:
or[image url="http://my.domain.com/picture.jpg"]
ⓘ Example usage:
[image url='http://my.domain.com/picture.jpg']
Putting " or ' inside of text parameter
If you need to pass " or ' in a text parameter, it may be interpreted as an end or beginning of a parameter itself. To avoid that just repeat same character (make double ' or double ").For example, to pass a text abc'd as a parameter you can do:
ⓘ Example usage:
[theTag key="abc''d"]