\HTMLPurifier_Injector_AutoParagraph
Injector that auto paragraphs text in the root node based on double-spacing.
Synopsis
class HTMLPurifier_Injector_AutoParagraph
extends HTMLPurifier_Injector
{
- // Inherited members from HTMLPurifier_Injector
- public $name;
- protected $htmlDefinition;
- protected $currentNesting;
- protected $inputTokens;
- protected $inputIndex;
- public array $needed;
- protected boolean $rewind;
- // methods
- private void _pStart()
- public void handleText()
- public void handleElement()
- private void _splitText()
- private void _isInline()
- private void _pLookAhead()
- private void _checkNeedsP()
- // Inherited methods from HTMLPurifier_Injector
- public void rewind()
- public void getRewind()
- public Boolean prepare()
- public Boolean checkNeeded()
- public True allowsElement()
- protected void forward()
- protected void forwardUntilEndToken()
- protected void backward()
- protected void current()
- public void handleText()
- public void handleElement()
- public void handleEnd()
- public void notifyEnd()
Hierarchy
Extends
Tasks
Line | Task |
---|---|
9+ | Ensure all states are unit tested, including variations as well. |
9+ | Make a graph of the flow control for this Injector. |
Members
protected
-
$currentNesting
Reference to CurrentNesting variable in Context. This is an array list of tokens that we are currently "inside" -
$htmlDefinition
Instance of HTMLPurifier_HTMLDefinition -
$inputIndex
Reference to InputIndex variable in Context. This is an integer array index for $this->inputTokens that indicates what token is currently being processed. -
$inputTokens
Reference to InputTokens variable in Context. This is an array list of the input tokens that are being processed. -
$rewind
Index of inputTokens to rewind to.
public
- $name
-
$name
Advisory name of injector, this is for friendly error messages - $needed
-
$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')
Methods
private
- _checkNeedsP() — Determines if a particular token requires an earlier inline token to get a paragraph. This should be used with _forwardUntilEndToken
- _isInline() — Returns true if passed token is inline (and, ergo, allowed in paragraph tags)
- _pLookAhead() — Looks ahead in the token list and determines whether or not we need to insert a <p> tag.
- _pStart()
- _splitText() — Splits up a text in paragraph tokens and appends them to the result stream that will replace the original
public
Inherited from HTMLPurifier_Injector
protected
- backward() — Iterator function, starts with the previous token and continues until you reach the beginning of input tokens.
- current() — Initializes the iterator at the current position. Use in a do {} while; loop to force the _forward and _backward functions to start at the current location.
- forward() — Iterator function, which starts with the next token and continues until you reach the end of the input tokens.
- forwardUntilEndToken() — 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.
public
- allowsElement() — Tests if the context node allows a certain element
- 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.
- getRewind() — Retrieves rewind, and then unsets it.
- handleElement() — Handler that is called when a start or empty token is processed
- handleEnd() — Handler that is called when an end token is processed
- handleText() — Handler that is called when a text token is processed
- notifyEnd() — Notifier that is called when an end token is processed
- 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()).
- rewind() — 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.