Jump to content

BBCode

From Wikipedia, the free encyclopedia
(Redirected from Bbcode)

Template:Short description Template:Distinguish BBCode ("Bulletin Board Code") is a lightweight markup language used to format messages in many Internet forum software. It was first introduced in 1998.[1] The available "tags" of BBCode are usually indicated by square brackets ([ and ]) surrounding a keyword, and is translated into HTML before being sent to the user.

Tags

Example in HTML/CSS BBCode Output
<syntaxhighlight lang="html">bolded text</syntaxhighlight>[2] or

<syntaxhighlight lang="html">bolded text</syntaxhighlight>

<syntaxhighlight lang="bbcode">[b]bolded text[/b]</syntaxhighlight> bolded text
<syntaxhighlight lang="html">italicized text</syntaxhighlight> or

<syntaxhighlight lang="html">italicized text</syntaxhighlight>

<syntaxhighlight lang="bbcode">[i]italicized text[/i]</syntaxhighlight> italicized text
<syntaxhighlight lang="html">underlined text</syntaxhighlight> or

<syntaxhighlight lang="html">underlined text</syntaxhighlight>

<syntaxhighlight lang="bbcode">[u]underlined text[/u]</syntaxhighlight> Template:Underline
<syntaxhighlight lang="html">strikethrough text</syntaxhighlight> or

<syntaxhighlight lang="html">strikethrough text</syntaxhighlight> or <syntaxhighlight lang="html">strikethrough text</syntaxhighlight>

<syntaxhighlight lang="bbcode">[s]strikethrough text[/s]</syntaxhighlight> strikethrough text
<syntaxhighlight lang="html"><a href="https://en.wikipedia.org">https://en.wikipedia.org</a></syntaxhighlight>

<syntaxhighlight lang="html"><a href="https://en.wikipedia.org">English Wikipedia</a></syntaxhighlight>

<syntaxhighlight lang="bbcode">[url]https://en.wikipedia.org[/url]</syntaxhighlight>

<syntaxhighlight lang="bbcode">[url=https://en.wikipedia.org]English Wikipedia[/url]</syntaxhighlight>

<syntaxhighlight lang="html"><img src="https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png" alt="Example image"></syntaxhighlight> <syntaxhighlight lang="bbcode">[img alt="Example image" ]https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png[/img]</syntaxhighlight> Example image
<syntaxhighlight lang="html"><img src="Smileys/Face-smile.svg" alt=":-)"></syntaxhighlight> <syntaxhighlight lang="bbcode">:)</syntaxhighlight> or <syntaxhighlight lang="bbcode">[:-)]</syntaxhighlight>

This would be another way to use the <syntaxhighlight lang="bbcode" inline>[img]url_img[/img]</syntaxhighlight> and must be pre-configured by the forum administrator. Template:Smalldiv

:-)

Template:Smalldiv

<syntaxhighlight lang="html">

quoted text

</syntaxhighlight> <syntaxhighlight lang="html">

quoted text

— author

</syntaxhighlight>

(Usually implemented in more advanced ways.)

<syntaxhighlight lang="bbcode">[quote]quoted text[/quote]</syntaxhighlight>

<syntaxhighlight lang="bbcode">[quote="author"]quoted text[/quote]</syntaxhighlight> (including optional author)

quoted text

quoted text

— author

<syntaxhighlight lang="html">
<code>computer code</code>
</syntaxhighlight>
<syntaxhighlight lang="bbcode">[code]computer code[/code]</syntaxhighlight> computer code
<syntaxhighlight lang="html">
monospaced text
</syntaxhighlight>
<syntaxhighlight lang="bbcode">[pre]monospaced text[/pre]</syntaxhighlight>
monospaced text
<syntaxhighlight lang="html">Large Text</syntaxhighlight> or <syntaxhighlight lang="html">Smaller Text</syntaxhighlight> <syntaxhighlight lang="bbcode">[style size="30px"]Large Text[/style]</syntaxhighlight>

<syntaxhighlight lang="bbcode">[style size="85"]Smaller Text[/style]</syntaxhighlight> or <syntaxhighlight lang="bbcode">[size="30px"]Large Text[/size]</syntaxhighlight> <syntaxhighlight lang="bbcode">[size="85"]Smaller Text[/size]</syntaxhighlight> (The unit of measurement varies with each BBCode variant and could represent pixels, points, or relative HTML sizes.)

Large Text
Smaller Text
<syntaxhighlight lang="html">Text in fuchsia</syntaxhighlight> or

<syntaxhighlight lang="html">Text in fuchsia</syntaxhighlight>

<syntaxhighlight lang="bbcode">[style color="fuchsia"]Text in fuchsia[/style]</syntaxhighlight> or

<syntaxhighlight lang="bbcode">[style color=#FF00FF]Text in fuchsia[/style]</syntaxhighlight> or <syntaxhighlight lang="bbcode">[color=#FF00FF]Text in fuchsia[/color]</syntaxhighlight> (Both HTML color names and hexadecimal color values are generally supported, although on some boards, you must omit the # from selecting a hexadecimal color.)

Text in fuchsia
<syntaxhighlight lang="html">
  • Entry A
  • Entry B
  1. Entry 1
  2. Entry 2

</syntaxhighlight>

<syntaxhighlight lang="bbcode">

[list]

 [*]Entry A
 [*]Entry B

[/list]

[list=1]

 [*]Entry 1
 [*]Entry 2

[/list] </syntaxhighlight> Some message boards do not need the square brackets around the markers.[3]

(Many variants for li and /li, list types – unordered and ordered, with different bullets or counter formats – etc.)

  • Entry A
  • Entry B
  1. Entry 1
  2. Entry 2
<syntaxhighlight lang="html">
column header 1 column header 2
table cell 1 table cell 2

</syntaxhighlight>

<syntaxhighlight lang="bbcode">

[table] [tr]

 [th]column header 1[/th]
 [th]column header 2[/th]

[/tr] [tr]

 [td]table cell 1[/td]
 [td]table cell 2[/td]

[/tr] [/table] </syntaxhighlight> (Some variants for thead, rules, etc.)

column header 1 column header 2
table cell 1 table cell 2
Source:[4]

Implementation

Template:Uncited section BBCode is typically implemented by applying a series of regular expression string-replace operations upon the input. Because regular expressions are limited in analyzing the structure of text input, this has the artifact that any non-hierarchical BBCode input will be transformed into invalid non-hierarchical HTML without error.

Applying traditional parsing techniques is made difficult by ambiguities in the markup, such as in <syntaxhighlight lang="text" class="" style="" inline="1">[quote=[b]text[/b][/quote]</syntaxhighlight>, where the input can either be interpreted as "text" quoted from someone called <syntaxhighlight lang="text" class="" style="" inline="1">[b</syntaxhighlight>, or the bolded text "text" surrounded by <syntaxhighlight lang="text" class="" style="" inline="1">[quote=</syntaxhighlight> and <syntaxhighlight lang="bbcode" class="" style="" inline="1">[/quote]</syntaxhighlight>, i.e. [quote=text[/quote].[5]

See also

Other lightweight markup languages:

References

  1. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
  2. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
  3. ↑ e.g. BOINC Project Forums et al.
  4. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
  5. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}