HTMLPurifier_Injector_RemoveEmpty
extends HTMLPurifier_Injector
in package
Injects tokens into the document while parsing for well-formedness.
This enables "formatter-like" functionality such as auto-paragraphing, smiley-ification and linkification to take place.
A note on how handlers create changes; this is done by assigning a new value to the $token reference. These values can take a variety of forms and are best described HTMLPurifier_Strategy_MakeWellFormed->processToken() documentation.
Table of Contents
Properties
- $name : mixed
- Advisory name of injector, this is for friendly error messages.
- $needed : mixed
- Array of elements and attributes this injector creates and therefore need to be allowed by the definition. Takes form of array('element' => array('attr', 'attr2'), 'element2')
- $currentNesting : mixed
- Reference to CurrentNesting variable in Context. This is an array list of tokens that we are currently "inside"
- $currentToken : mixed
- Reference to current token.
- $htmlDefinition : mixed
- $inputZipper : mixed
- Reference to InputZipper variable in Context.
- $rewindOffset : mixed
- Number of elements to rewind backwards (relative).
- $attrValidator : mixed
- $config : mixed
- $context : mixed
- $exclude : mixed
- Cached contents of %AutoFormat.RemoveEmpty.Predicate
- $removeNbsp : mixed
- $removeNbspExceptions : mixed
Methods
- allowsElement() : bool
- Tests if the context node allows a certain element
- checkNeeded() : bool|string
- This function checks if the HTML environment will work with the Injector: if p tags are not allowed, the Auto-Paragraphing injector should not be enabled.
- getRewindOffset() : bool|int
- Retrieves rewind offset, and then unsets it.
- handleElement() : mixed
- Handler that is called when a start or empty token is processed
- handleEnd() : mixed
- Handler that is called when an end token is processed
- handleText() : mixed
- Handler that is called when a text token is processed
- notifyEnd() : mixed
- Notifier that is called when an end token is processed
- prepare() : void
- Prepares the injector by giving it the config and context objects: this allows references to important variables to be made within the injector. This function also checks if the HTML environment will work with the Injector (see checkNeeded()).
- rewindOffset() : mixed
- Rewind to a spot to re-perform processing. This is useful if you deleted a node, and now need to see if this change affected any earlier nodes. Rewinding does not affect other injectors, and can result in infinite loops if not used carefully.
- backward() : bool
- Iterator function, starts with the previous token and continues until you reach the beginning of input tokens.
- forward() : bool
- Iterator function, which starts with the next token and continues until you reach the end of the input tokens.
- forwardUntilEndToken() : bool
- Similar to _forward, but accepts a third parameter $nesting (which should be initialized at 0) and stops when we hit the end tag for the node $this->inputIndex starts in.
Properties
$name
Advisory name of injector, this is for friendly error messages.
public
mixed
$name
Tags
$needed
Array of elements and attributes this injector creates and therefore need to be allowed by the definition. Takes form of array('element' => array('attr', 'attr2'), 'element2')
public
mixed
$needed
= array()
Tags
$currentNesting
Reference to CurrentNesting variable in Context. This is an array list of tokens that we are currently "inside"
protected
mixed
$currentNesting
Tags
$currentToken
Reference to current token.
protected
mixed
$currentToken
Tags
$htmlDefinition
protected
mixed
$htmlDefinition
Tags
$inputZipper
Reference to InputZipper variable in Context.
protected
mixed
$inputZipper
Tags
$rewindOffset
Number of elements to rewind backwards (relative).
protected
mixed
$rewindOffset
= \false
Tags
$attrValidator
private
mixed
$attrValidator
Tags
$config
private
mixed
$config
Tags
$context
private
mixed
$context
Tags
$exclude
Cached contents of %AutoFormat.RemoveEmpty.Predicate
private
mixed
$exclude
Tags
$removeNbsp
private
mixed
$removeNbsp
Tags
$removeNbspExceptions
private
mixed
$removeNbspExceptions
Tags
Methods
allowsElement()
Tests if the context node allows a certain element
public
allowsElement(string $name) : bool
Parameters
- $name : string
-
Name of element to test for
Return values
bool —True if element is allowed, false if it is not
checkNeeded()
This function checks if the HTML environment will work with the Injector: if p tags are not allowed, the Auto-Paragraphing injector should not be enabled.
public
checkNeeded(HTMLPurifier_Config $config) : bool|string
Parameters
- $config : HTMLPurifier_Config
Return values
bool|string —Boolean false if success, string of missing needed element/attribute if failure
getRewindOffset()
Retrieves rewind offset, and then unsets it.
public
getRewindOffset() : bool|int
Return values
bool|inthandleElement()
Handler that is called when a start or empty token is processed
public
handleElement(HTMLPurifier_Token &$token) : mixed
Parameters
- $token : HTMLPurifier_Token
handleEnd()
Handler that is called when an end token is processed
public
handleEnd(mixed &$token) : mixed
Parameters
- $token : mixed
handleText()
Handler that is called when a text token is processed
public
handleText(mixed &$token) : mixed
Parameters
- $token : mixed
notifyEnd()
Notifier that is called when an end token is processed
public
notifyEnd(HTMLPurifier_Token $token) : mixed
Parameters
- $token : HTMLPurifier_Token
-
Current token variable.
Tags
prepare()
Prepares the injector by giving it the config and context objects: this allows references to important variables to be made within the injector. This function also checks if the HTML environment will work with the Injector (see checkNeeded()).
public
prepare(HTMLPurifier_Config $config, HTMLPurifier_Context $context) : void
Parameters
- $config : HTMLPurifier_Config
- $context : HTMLPurifier_Context
rewindOffset()
Rewind to a spot to re-perform processing. This is useful if you deleted a node, and now need to see if this change affected any earlier nodes. Rewinding does not affect other injectors, and can result in infinite loops if not used carefully.
public
rewindOffset(bool|int $offset) : mixed
Parameters
- $offset : bool|int
Tags
backward()
Iterator function, starts with the previous token and continues until you reach the beginning of input tokens.
protected
backward(int &$i, HTMLPurifier_Token &$current) : bool
Parameters
- $i : int
-
Current integer index variable for inputTokens
- $current : HTMLPurifier_Token
-
Current token variable. Do NOT use $token, as that variable is also a reference
Tags
Return values
boolforward()
Iterator function, which starts with the next token and continues until you reach the end of the input tokens.
protected
forward(int &$i, HTMLPurifier_Token &$current) : bool
Parameters
- $i : int
-
Current integer index variable for inputTokens
- $current : HTMLPurifier_Token
-
Current token variable. Do NOT use $token, as that variable is also a reference
Tags
Return values
boolforwardUntilEndToken()
Similar to _forward, but accepts a third parameter $nesting (which should be initialized at 0) and stops when we hit the end tag for the node $this->inputIndex starts in.
protected
forwardUntilEndToken(int &$i, HTMLPurifier_Token &$current, int &$nesting) : bool
Parameters
- $i : int
-
Current integer index variable for inputTokens
- $current : HTMLPurifier_Token
-
Current token variable. Do NOT use $token, as that variable is also a reference
- $nesting : int