vBulletin v6.0.4

vB_WysiwygHtmlParser
in package
Uses vB_Trait_NoSerialize

Class to parse the HTML generated by the WYSIWYG editor to BB code.

Can be extended to parse additional tags or change the parsing behavior.

This class can be used for generic HTML to BB code conversions, but it is not always ideally suited to this.

Table of Contents

Methods

__construct()  : mixed
Constructor. Automatically loads the tag rules.
__serialize()  : array<string|int, mixed>
__sleep()  : array<string|int, mixed>
__unserialize()  : void
__wakeup()  : void
cleanupAfter()  : string
Post parsing clean up. Removes unparsed HTML and sanitizes some BB codes.
filterBefore()  : string
Template method for pre-filtering the HTML before it is parsed.
inState()  : bool
Determines whether the parser is in the named state.
loadTagRules()  : array<string|int, mixed>
Returns the rule set for parsing matched tags. Array key is name of HTML tag to match. Value is either a simple callback or an array with keys 'callback' and 'param' (an optional extra value to pass in to the parsing callback function). Callbacks may refer to the string $this to refer to the current class instance.
parseHtml()  : string
Parses the HTML tags within a string.
parseTagByName()  : mixed
Parses a matched HTML tag by the name of the tag. This is resolved to the tag parsing rules array and handled from there.
parseWysiwygHtmlToBbcode()  : string
Parses the specified HTML into BB code
setPLinebreaks()  : mixed
Sets the number of line breaks a <p> tag inserts.

Methods

__construct()

Constructor. Automatically loads the tag rules.

public __construct() : mixed

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__sleep()

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(array<string|int, mixed> $serialized) : void
Parameters
$serialized : array<string|int, mixed>

cleanupAfter()

Post parsing clean up. Removes unparsed HTML and sanitizes some BB codes.

public cleanupAfter(mixed $text) : string
Parameters
$text : mixed
Return values
string

Text post-cleanup

filterBefore()

Template method for pre-filtering the HTML before it is parsed.

public filterBefore(mixed $text) : string

Filters things like BB code mixed into HTML, browser specific wrapping, and HTML within BB codes that don't support nested tags.

Parameters
$text : mixed
Return values
string

Text post-filter

inState()

Determines whether the parser is in the named state.

public inState(mixed $state) : bool

Note that a parser can be in multiple states simultaneously. The state is not tracked with a stack.

Parameters
$state : mixed
Return values
bool

loadTagRules()

Returns the rule set for parsing matched tags. Array key is name of HTML tag to match. Value is either a simple callback or an array with keys 'callback' and 'param' (an optional extra value to pass in to the parsing callback function). Callbacks may refer to the string $this to refer to the current class instance.

public loadTagRules() : array<string|int, mixed>
Return values
array<string|int, mixed>

parseHtml()

Parses the HTML tags within a string.

public parseHtml(mixed $text) : string

Handles matched and special unmatched tags.

Parameters
$text : mixed
Return values
string

Parsed text (BB code)

parseTagByName()

Parses a matched HTML tag by the name of the tag. This is resolved to the tag parsing rules array and handled from there.

public parseTagByName(mixed $tagName, mixed $text[, mixed $forceParam = null ]) : mixed
Parameters
$tagName : mixed
$text : mixed
$forceParam : mixed = null

parseWysiwygHtmlToBbcode()

Parses the specified HTML into BB code

public parseWysiwygHtmlToBbcode(mixed $unparsed[, mixed $allowHtml = false ]) : string
Parameters
$unparsed : mixed
$allowHtml : mixed = false
Return values
string

Parsed version (BB code)

setPLinebreaks()

Sets the number of line breaks a <p> tag inserts.

public setPLinebreaks(mixed $linebreaks) : mixed
Parameters
$linebreaks : mixed

        
On this page

Search results