function hook_xbbcode_info in Extensible BBCode 7
Same name and namespace in other branches
- 8 xbbcode.api.php \hook_xbbcode_info()
- 8.2 xbbcode.api.php \hook_xbbcode_info()
Define tags that can be used by XBBCode.
A tag is uniquely identified by a (lowercase alphabetic) name. It must include a description and a sample, both of which should already be localized. It must include either a markup template or a callback function.
If a markup template is used, then the template should contain placeholders that will be replaced with the tag's content and attributes:
- {content}: The text between opening and closing tags (non-inclusive), assuming the tag is not self-closing.
- {option}: The single attribute of the tag, if one is entered.
- {...}: If a named attribute is entered, it will replace the placeholder of the same name. Otherwise, the placeholder is removed.
For example, if [url=http://www.drupal.org]Drupal[/url] is entered, then {content} will be replaced with "Drupal" and {option} with "http://www.drupal.org". In [img width=60 height=60], {width} and {height} will be replaced with "60".
Return value
An array keyed by tag name, each element of which must contain these keys:
- EITHER markup: A string of HTML code.
- OR callback: A rendering function to call. See hook_xbbcode_TAG_render() for details.
- options: An array that can contain any of the following keys.
- nocode: All tags inside the content of this tag will not be parsed
- plain: HTML inside the content of this tag will always be escaped.
- selfclosing: This tag closes itself, as in [img=http://url].
- sample: For the help text, provide an example of the tag in use. This sample will be displayed along with its rendered output.
- description: A description of the tag.
The "sample" and "description" values should be localized with t().
5 functions implement hook_xbbcode_info()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- xbbcode_basic_xbbcode_info in xbbcode_basic/
xbbcode_basic.module - xbbcode_highlighter_xbbcode_info in xbbcode_highlighter/
xbbcode_highlighter.module - Implements hook_xbbcode_info().
- xbbcode_list_xbbcode_info in xbbcode_list/
xbbcode_list.module - xbbcode_table_xbbcode_info in xbbcode_table/
xbbcode_table.module - Implements hook_xbbcode_info().
- xbbcode_xbbcode_info in ./
xbbcode.module - Implements hook_xbbcode_info().
5 invocations of hook_xbbcode_info()
- xbbcode_modules_disabled in ./
xbbcode.module - Implements hook_modules_disabled().
- xbbcode_modules_enabled in ./
xbbcode.module - Implements hook_modules_enabled().
- _xbbcode_build_handlers in ./
xbbcode.inc - Discover the handlers by module hook invokation.
- _xbbcode_build_tags in ./
xbbcode.inc - Invoke all handlers to get the tags for a certain format.
- _xbbcode_module_names in ./
xbbcode.inc - End-user names of all modules that implement hook_xbbcode_info().
File
- ./
xbbcode.api.php, line 48 - Hooks provided by the XBBCode module.
Code
function hook_xbbcode_info() {
$tags['url'] = array(
'markup' => '<a href="{option}">{content}</a>',
'description' => 'A hyperlink.',
'sample' => '[url=http://drupal.org/]Drupal[/url]',
);
$tags['img'] = array(
'markup' => '<img src="{option}" />',
'options' => array(
'selfclosing' => TRUE,
),
'description' => 'An image',
'sample' => '[img=http://drupal.org/favicon.ico]',
);
$tags['code'] = array(
'markup' => '<code>{option}</code>',
'options' => array(
'nocode' => TRUE,
'plain' => TRUE,
),
'description' => 'Code',
'sample' => '[code]if (x <> 3) then y = (x <= 3)[/code]',
);
$tags['php'] = array(
'callback' => 'hook_xbbcode_TAG_render',
'options' => array(
'nocode' => TRUE,
'plain' => TRUE,
),
'description' => 'Highlighed PHP code',
'sample' => '[php]print "Hello world";[/php]',
);
return $tags;
}