BBcode

From auWiki
Jump to navigation Jump to search

BBcode is an intermediate form of limited HTML that allows users some basic formatting without allowing the whole of what HTML supports. auLib provides functions in the auText class to convert between BBcode and HTML. This page lists the formatting supported.

Bold

[b]bold text[/b]

Any text between [b] and [/b] is formatted bold using the HTML b tag.

Italic

[i]italic text[/i]

Any text between [i] and [/i] is formatted italic using the HTML i tag.

Link

[link=http://www.example.com/]linked text[/link]
[url=http://www.example.com/]linked text[/url]

Hyperlinks can be created using either link or url; it’s even possible to mix the two, opening with one and closing with the other. The value after the equal sign should be a valid URL but doesn’t need to start with http:// (it’s acceptable to use something like /section/page.php or #id to link to something on the same site or even the same page, for example). The linked text is used as the text of the hyperlink.

Quote

[q=author]quoted text[/q]
[q]quoted text[/q]

There are two options for quotes. The first example shows a quote with attribution while the second only indicates that whoever is posting the quote didn’t write it. Both cases enclose the quoted text in the HTML blockquote tag. The first case also includes an HTML cite tag before the quote with “author says:” as its contents. Features that allow a user to reply to another user would normally use the first method to include the quoted username as the author and their post contents as quoted text.

Lists

[numbers]
first list item
second list item
[/numbers]
[bullets]
first list item
second list item
[/bullets]

Both numbered and bulletted lists are available by putting each list item on its own line and surrounded by either [numbers] or [bullets] accordingly. At this time, lists may only have one level.

Code

[code]
code block
[/code]
[code]code block[/code]
non-code text [code]inline code[/code] more non-code text

There are two options for code, both using the same BBcode tag. Inline code needs to have both [code] and [/code] on the same line, and they cannot be at the beginning and end of the line (otherwise it looks like a one-line code block). Inline code uses the HTML code tag while code blocks use the HTML samp tag.

Headings

[head]heading[/head]
[subhead]subheading[/subhead]

Headings (and subheadings) are ignored by default and must be enabled in auText::BB2HTML() by passing true for the $head parameter. Headings become the HTML h2 tag and subheadings become h3.