BBCode Functions
Introduction
This extension aims to help parse BBCode text in order to convert it to HTML or another markup language. It uses one pass parsing and provides great speed improvement over the common approach based on regular expressions. Further more, it helps provide valid HTML by reordering open / close tags and by automatically closing unclosed tags.
Since 0.10.1 It supports argument quoting with single quotes, double quotes and HTML escaped double quotes.
Installation
Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: » https://pecl.php.net/package/bbcode
An alternative solution, written in PHP, is the PEAR package » HTML_BBCodeParser.
Runtime Configuration
Tämä laajennus ei määrittele yhtäkään direktiiviä php.inissä.
Resource Types
One resource is used in the BBCode extension: a BBCode_Container returned by bbcode_create().
Predefined Constants
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
- BBCODE_TYPE_NOARG (integer)
- This BBCode tag does not accept any arguments.
- BBCODE_TYPE_SINGLE (integer)
- This BBCode tag does not have a corresponding close tag.
- BBCODE_TYPE_ARG (integer)
- This BBCode tag need an argument.
- BBCODE_TYPE_OPTARG (integer)
- This BBCode tag accept an optional argument.
- BBCODE_TYPE_ROOT (integer)
- This BBCode tag is the special tag root (nesting level 0).
- BBCODE_FLAGS_ARG_PARSING (integer)
- This BBCode tag require argument sub-parsing (the argument is also parsed by the BBCode extension). As Of 0.10.2 another parser can be used as argument parser.
- BBCODE_FLAGS_CDATA_NOT_ALLOWED (integer)
- This BBCode Tag does not accept content (it voids it automatically).
- BBCODE_FLAGS_SMILEYS_ON (integer) - since 0.10.2
- This BBCode Tag accepts smileys.
- BBCODE_FLAGS_SMILEYS_OFF (integer) - since 0.10.2
- This BBCode Tag does not accept smileys.
- BBCODE_FLAGS_ONE_OPEN_PER_LEVEL (integer) - since 0.10.2
- This BBCode Tag automatically closes if another tag of the same type is found at the same nesting level.
- BBCODE_FLAGS_REMOVE_IF_EMPTY (integer) - since 0.10.2
- This BBCode Tag is automatically removed if content is empty it allows to produce ligther HTML.
- BBCODE_FLAGS_DENY_REOPEN_CHILD (integer) - since 0.10.3
- This BBCode Tag does not allow unclosed childs to reopen when automatically closed.
- BBCODE_ARG_DOUBLE_QUOTE (integer) - since 0.10.2
- This is a parser option allowing argument quoting with double quotes (")
- BBCODE_ARG_SINGLE_QUOTE (integer) - since 0.10.2
- This is a parser option allowing argument quoting with single quotes (')
- BBCODE_ARG_HTML_QUOTE (integer) - since 0.10.2
- This is a parser option allowing argument quoting with HTML version of double quotes (")
- BBCODE_AUTO_CORRECT (integer) - since 0.10.2
- This is a parser option changing the way errors are treated. It automatically closes tag in the order they are opened. And treat tags with only an open tag as if there were a close tag present.
- BBCODE_CORRECT_REOPEN_TAGS (integer) - since 0.10.2
- This is a parser option changing the way errors are treated. It automatically reopens tag if close tags are not in the good order.
- BBCODE_DISABLE_TREE_BUILD (integer) - since 0.10.2
- This is a parser option disabling the BBCode parsing it can be useful if only the "smiley" replacement must be used.
- BBCODE_DEFAULT_SMILEYS_ON (integer) - since 0.10.2
- This is a parser option setting smileys to ON if no flag is given at tag level.
- BBCODE_DEFAULT_SMILEYS_OFF (integer) - since 0.10.2
- This is a parser option setting smileys to OFF if no flag is given at tag level.
- BBCODE_FORCE_SMILEYS_OFF (integer) - since 0.10.2
- This is a parser option disabling completely the smileys parsing.
- BBCODE_SMILEYS_CASE_INSENSITIVE (integer) - since 0.10.3
- Use a case insensitive Detection for smileys instead of a simple binary search.
- BBCODE_SET_FLAGS_SET (integer) - since 0.10.2
- This permits to SET the complete flag set on a parser.
- BBCODE_SET_FLAGS_ADD (integer) - since 0.10.2
- This permits to switch a flag set ON on a parser.
- BBCODE_SET_FLAGS_REMOVE (integer) - since 0.10.2
- This permits to switch a flag set OFF on a parser.
Table of Contents
- bbcode_add_element — Adds a bbcode element
- bbcode_add_smiley — Adds a smiley to the parser
- bbcode_create — Create a BBCode Resource
- bbcode_destroy — Close BBCode_container resource
- bbcode_parse — Parse a string following a given rule set
- bbcode_set_arg_parser — Attach another parser in order to use another rule set for argument parsing
- bbcode_set_flags — Set or alter parser options