mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
.. | ||
bbcpputils.cpp | ||
bbcpputils.h | ||
BBDocument.cpp | ||
BBDocument.h | ||
LICENSE | ||
README.md | ||
SCsub |
bbcpp
Introduction
bbcpp is a C++ library for parsing BBCode, or Bulletin Board Code, a markup language used to format posts in many message boards.
This library parses BBCode into a tree data structure that can be used to format output. However, this library does not include any output classes, though a basic HTML output class will likely be included.
Usage
auto doc = BBDocument::create();
doc->load("This is [b]an example[/b] of some text.");
Element Types
Examples:
[B] - Bold text
[I] - Italicized text
[QUOTE] - Blockquote text (without specifiers as discussed below)
Value Elements
Examples
[COLOR="green"]
[FONT="Arial Narrow"]
[SIZE="5"]
[EMAIL="billgates@microsoft.com"]
The QUOTE
Element
The bbcpp parser will accept three different formats for the QUOTE
tag:
[QUOTE user=Username postid=1234]
: A key-value pair of values. In theory they are space delimited unless quoted. (Used with phpBB)[QUOTE="username, post: 1799684, member: 11733"]
: Another key-value pair format except the first argument is assumed to be the username. (Used with XenForo)[QUOTE=Username;1234]
:Username
is the name of the user being quoted and1234
is the postid. (Used with vBulletin)
FONT
COLOR
LIST
/[*]
IMG
URL
BBNode Tree
The following are examples of the node tree built during parsing.
Example 1
This is [b]an example[/b] of some text
#document
│-- @"This is"
│-- [b]
│ │-- @"an example"
│ │-- [/b]
│-- @"of some text"
Example 2
[QUOTE]This is [b]important[/b] news![/QUOTE]
Indeed it is!
#document
│-- [QUOTE]
│ │-- @"This is "
│ │-- [b]
| | |-- @"important"
| | |-- [/b]
│ │-- @"news!"
│ │-- [/QUOTE]
│-- @"\n\nIndeed it is!"
Example 3
[QUOTE user=Joe userid=1 postid=1234]This is another quote![/QUOTE]
I'm quoting you!
#document
│-- [QUOTE]
| |-- {user=Joe}
| |-- {userid=1}
| |-- {postid=1234}
│ │-- @"This is another quote!"
│ │-- [/QUOTE]
│-- @"\n\nI'm quoting you!"