BBCode

Revision as of 18:47, 18 May 2025 by imported>Peaceray (Rollback edit(s) by 2001:A62:630:2101:C9FE:1FD0:39AC:BABD (talk): Reverting good faith edits: it has been fixed, so to "simply reinstate" is appropriate (RW 16.1))
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> The available "tags" of BBCode are usually indicated by square brackets ([ and ]) surrounding a keyword, and are parsed before being translated into HTML.Template:Cn

TagsEdit

Example in HTML/CSS BBCode Output
citation CitationClass=web

}}</ref>,
<syntaxhighlight lang="html" inline>bolded text</syntaxhighlight> or
<syntaxhighlight lang="html" inline>bolded text</syntaxhighlight>

<syntaxhighlight lang="bbcode" inline>[b]bolded text[/b]</syntaxhighlight> bolded text
<syntaxhighlight lang="html" inline>italicized text</syntaxhighlight>,
<syntaxhighlight lang="html" inline>italicized text</syntaxhighlight> or
<syntaxhighlight lang="html" inline>italicized text</syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[i]italicized text[/i]</syntaxhighlight> italicized text
<syntaxhighlight lang="html" inline>underlined text</syntaxhighlight> or
<syntaxhighlight lang="html" inline>underlined text</syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[u]underlined text[/u]</syntaxhighlight> underlined text
<syntaxhighlight lang="html" inline>strikethrough text</syntaxhighlight> or
<syntaxhighlight lang="html" inline>strikethrough text</syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[s]strikethrough text[/s]</syntaxhighlight> strikethrough text
<syntaxhighlight lang="html" inline><a href="https://en.wikipedia.org">https://en.wikipedia.org</a></syntaxhighlight>
<syntaxhighlight lang="html" inline><a href="https://en.wikipedia.org">English Wikipedia</a></syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[url]https://en.wikipedia.org[/url]</syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[url=https://en.wikipedia.org]English Wikipedia[/url]</syntaxhighlight>
https://en.wikipedia.org
English Wikipedia
<syntaxhighlight lang="html" inline=""><img src="https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png" alt="This is just an example" /></syntaxhighlight> <syntaxhighlight lang="bbcode" inline="">[img alt="This is just an example" ]https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png[/img]</syntaxhighlight> File:Example.png
<syntaxhighlight lang="html" inline><img src="Smileys/Face-smile.svg" alt=":-)"></syntaxhighlight> <syntaxhighlight lang="bbcode" inline>:)</syntaxhighlight> or <syntaxhighlight lang="bbcode" inline>[:-)]</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.
(This and other emoticons, depending on the variant. Most BBCodes do not enclose emoticons in square brackets, leading to frequent accidental usage.)
:-)
(Specific image and size vary.)
<syntaxhighlight lang="html" inline>

quoted text

</syntaxhighlight>
(Usually implemented in more advanced ways.)
<syntaxhighlight lang="bbcode" inline>[quote]quoted text[/quote]</syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[quote="author"]quoted text[/quote]</syntaxhighlight>
(including optional author)
Using a Wikipedia template: Template:QuoteTemplate:Quote
<syntaxhighlight lang="html" inline>
monospaced text
</syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[code]monospaced text[/code]</syntaxhighlight> monospaced text
<syntaxhighlight lang="html" inline>Large Text</syntaxhighlight> or
<syntaxhighlight lang="html" inline>Smaller Text</syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[style size="30px"]Large Text[/style]</syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[style size="85"]Smaller Text[/style]</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" inline>Text in fuchsia</syntaxhighlight> or
<syntaxhighlight lang="html" inline>Text in fuchsia</syntaxhighlight>
<syntaxhighlight lang="bbcode" inline>[style color="fuchsia"]Text in fuchsia[/style]</syntaxhighlight> or
<syntaxhighlight lang="bbcode" inline>[style color=#FF00FF]Text in fuchsia[/style]</syntaxhighlight> or
<syntaxhighlight lang="bbcode" inline>[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.<ref>e.g. BOINC Project Forums et al.</ref>

(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">
table cell 1 table cell 2
table cell 3 table cell 4

</syntaxhighlight>

<syntaxhighlight lang="bbcode">

[table] [tr]

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

[/tr] [tr]

 [td]table cell 3[/td]
 [td]table cell 4[/td]

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

table cell 1 table cell 2
table cell 3 table cell 4
Source:<ref>{{#invoke:citation/CS1|citation CitationClass=web

}}</ref>

ImplementationEdit

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.Template:Citation needed

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].

See alsoEdit

ReferencesEdit

<references />

External linksEdit