BitOwl Application Suit provides a limited BB code parser. To use simply
pass in the BB code encoded string to str parseBBCode(str $string, callback $attachment_callback=false)
.
The following codes are supported.
[b]{text}[/b]
Creates bold face text.
[i]{text}[/i]
Creates italic text.
[u]{text}[/u]
Creates underlined text.
[s]{text}[/s]
Creates strikethrough text.
[img]{url}[/img]
Displays the image at the specified url.
[url[={url}]]{text/url}[/url]
Either links the text with the specified url or make the url a hyperlink.
[youtube]{id}[/youtube]
Embeds a youtube video, include only the part after the "v=".
[break]
Adds a space. Could be used to separate paragraphs.
[attachment={index}]{text}[/attachment]
If $attachment_callback
is provided this will execute the
function. The result of this code is dependant on said function.
For each call to parseBBCode
an attachment callback can be
provided. This is the name of the function in which to call to parse the
attachment BB code. The function must have the following prototype:
str function functionName($number, $innerValue)
. $number
is the value passed in as the argument to the BB code. $innerValue
is the text between the starting and closing tags.