IV. API Reference

[ Previous: D. Content-Trimming Functions | Next: F. Rule Functions ]

E. Root-Class Functions

void BBCode::SetRootInline ( )
This function tells NBBC that the BBCode content to be formatted is inline content --- it's part of another paragraph --- which means it cannot contain block formatting tags such as [center] and [columns] and [quote] and [code]. Any attempts to use those tags will result in them appearing verbatim, as if they were not registered rules or tags at all. This inline mode is most useful when you have content that must be joined to other pre-existing content.

As always, whether in inline mode or in block mode, NBBC does not wrap the output in an HTML element of any kind: Generally, you will want to wrap the output in a <span> element (when inline mode is active), but you do not have to if that doesn't fit your needs.
Parameters: None.
Return Value: None.
Notes:
The best way to understand the difference between the root class being "inline" and the root class being "block" is to see an example. Consider the BBCode below:
Code:
[center]This is a [i]test[/i].[/center]
In block mode, this BBCode would be converted to:
Output:
<div style="text-align:center">This is a <i>test</i>.</div>
But in inline mode, this same BBCode would be converted to this instead:
Output:
[center]This is a <i>test</i>.[/center]
Notice that in inline mode, NBBC refuses to generate <div> tags in the output; this is because inline mode means that you intend to put the content inside a <span> or equivalent element, and <div> is illegal inside <span>, so all tags that might require <div> or similar block layouts become forbidden: In short, only text-style tags like [i] and [b] and [font], and link tags like [url] and [wiki], and [img] tags (and smileys!) --- tags that affect the current line of text but that don't start a new one --- are allowed in inline mode, while all tags are allowed in block mode.
void BBCode::SetRootBlock ( )
This function tells NBBC that the BBCode content to be formatted is block content --- it's not part of another paragraph, and likely will be wrapped in its own <div> element by the caller. In block mode, all BBCode tags are legal (contrast this with inline mode where only text-style tags, link tags, and images are legal).

Note that even in block mode, you cannot (should not) wrap the output inside an HTML <p> element, because <p> is actually very restricted in the kinds of content it can contain: For example, the <table> element used by NBBC to create columns is illegal inside a <p> element. So if you need to wrap your output in a single HTML element, you should use a <div> element.

As always, whether in inline mode or in block mode, NBBC does not wrap the output in an HTML element of any kind: Generally, you will want to wrap the output in a <div> element (when block mode is active), but you do not have to if that doesn't fit your needs.
Parameters: None.
Return Value: None.
void BBCode::SetRoot ( string $class )
This function controls the root class NBBC uses. The classes NBBC normally uses for root classes are "block" and "inline", but if you create new classes, you can tell NBBC to start with one of those instead using this function.
Parameters:
  • class: A classname to use as the root class. See the appendix on content classes for more details.
Return Value: None.
string BBCode::GetRoot ( )
This function returns the currently-selected root class, usually either "block" or "inline". See SetRootInline(), SetRootBlock(), or SetRoot() for more details.
Return values: The currently-selected root class.

[ Previous: D. Content-Trimming Functions | Next: F. Rule Functions ]


Copyright © 2010, the Phantom Inker. All rights reserved.