Abstract visitor base for RST documents represented by the parser AST.
Source for this file: /Document/src/document/rst/visitor.php
Version: | //autogen// |
Child Class | Description |
---|---|
ezcDocumentRstXhtmlVisitor | HTML visitor for the RST AST. |
ezcDocumentRstDocbookVisitor | Docbook visitor for the RST AST. |
DUBLICATE
= 4
|
Duplicate reference target. Will throw an error on use. |
UNUSED
= 1
|
Unused reference target |
USED
= 2
|
Used reference target |
protected int |
$anonymousReferenceCounter
= 0
Index of last requested anonymous reference target. |
protected array |
$anonymousReferences
= array()
Collected anonymous externals reference targets |
protected ezcDocumentRstDocumentNode |
$ast
Reference to the AST root node. |
protected array |
$errors
= array()
Aggregated minor errors during document processing. |
protected array |
$footnoteCounter
= array( 0 )
Label dependant foot note counters for footnote auto enumeration. |
protected array |
$footnotes
= array()
List with footnotes for later rendering. |
protected array |
$footnoteSymbols
= array(
Foot note symbol signs, as defined at http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#auto-symbol-footnotes |
protected array |
$namedExternalReferences
= array()
Collected named external reference targets |
protected string |
$path
Location of the currently processed RST file, relevant for inclusion. |
protected array |
$referenceCounter
= array()
Counter of duplicate references for duplicate references. |
protected array |
$references
= array()
Collected refrence targets. |
protected ezcDocumentRst |
$rst
RST document handler |
protected array |
$substitutions
= array()
Collected substitutions. |
protected array |
$usedIDs
= array()
Array of already generated IDs, so none will be used twice. |
public void |
__construct(
$document
, $path
)
Create visitor from RST document handler. |
protected void |
addFootnote(
$node
)
Add footnote |
protected void |
aggregateListItems(
$node
)
Aggregate list items |
protected string |
calculateId(
$string
)
Get a valid identifier string |
protected string |
calculateUniqueId(
$string
)
Calculate unique ID |
protected bool |
compareListType(
$item
, $lastItem
)
Compare two list items |
public string |
getAnonymousReferenceTarget(
)
Get anonymous reference target |
public array |
getErrors(
)
Return list of errors occured during visiting the document. |
public string |
getNamedExternalReference(
$name
)
Return named external reference target |
public ezcDocumentRstFootnoteNode |
hasFootnoteTarget(
$string
, $node
)
Check for internal footnote reference target |
public string |
hasReferenceTarget(
$string
, [ $node
= null] , [ $force
= false] )
Check for internal reference target |
public string |
nodeToString(
$node
)
Transform a node tree into a string |
protected void |
preProcessAst(
$node
)
Pre process AST |
protected void |
substitute(
$string
)
Get substitution contents |
protected string |
tokenListToString(
$tokens
)
Get string from token list. |
public void |
triggerError(
$level
, $message
, [ $file
= null] , [ $line
= null] , [ $position
= null] )
Trigger visitor error |
public mixed |
visit(
$ast
)
Docarate RST AST |
protected void |
visitChildren(
$root
, $node
)
Visit children |
protected void |
visitSubstitutionReference(
$root
, $node
)
Visit substitution reference node |
protected void |
visitText(
$root
, $node
)
Visit text node |
Create visitor from RST document handler.
Name | Type | Description |
---|---|---|
$document |
ezcDocumentRst | |
$path |
string |
Method | Description |
---|---|
ezcDocumentRstXhtmlVisitor::__construct() |
Create visitor from RST document handler. |
Add footnote
Name | Type | Description |
---|---|---|
$node |
ezcDocumentRstNode |
Aggregate list items
Aggregate list items into lists. In RST there are only list items, which are aggregated to lists depending on their bullet type. The related list items are aggregated into one list.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentRstNode |
Get a valid identifier string
Get a valid identifier string from an arbritrary string.
Name | Type | Description |
---|---|---|
$string |
string |
Calculate unique ID
Calculate a valid identifier, which is unique for this document.
Name | Type | Description |
---|---|---|
$string |
string |
Compare two list items
Check if the given list item may be a successor in the same list, as the last item in the list. Returns the boolean status o the check.
Name | Type | Description |
---|---|---|
$item |
ezcDocumentRstNode | |
$lastItem |
ezcDocumentRstNode |
Get anonymous reference target
Get the target URL of an anonomyous reference target.
Return list of errors occured during visiting the document.
May be an empty array, if on errors occured, or a list of ezcDocumentVisitException objects.
Method | Description |
---|---|
ezcDocumentErrorReporting::getErrors() |
Return list of errors occured during visiting the document. |
Return named external reference target
Get the target value of a named external reference.
Name | Type | Description |
---|---|---|
$name |
string |
Check for internal footnote reference target
Returns the target name, when an internal reference target exists and sets it to used, and false otherwise.
Name | Type | Description |
---|---|---|
$string |
string | |
$node |
ezcDocumentRstNode |
Check for internal reference target
Returns the target name, when an internal reference target exists and sets it to used, and false otherwise. For duplicate reference targets and missing reference targets an error will be triggered.
An optional third parameter may enforce the fetching of the reference, even if there are duplicates, so that they still can be referenced in some way.
Name | Type | Description |
---|---|---|
$string |
string | |
$node |
ezcDocumentRstNode | |
$force |
bool |
Transform a node tree into a string
Transform a node tree, with all its subnodes into a string by only getting the textuual contents from ezcDocumentRstTextLineNode objects.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentRstNode |
Pre process AST
Performs multiple preprocessing steps on the AST:
Collect all possible reference targets in the AST to know the actual destianation for references while decorating. The references are stored in an internal structure and you may request the actual link by using the getReferenceTarget() method.
Aggregate list items into lists. In RST there are only list items, which are aggregated to lists depending on their bullet type. The related list items are aggregated into one list.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentRstNode |
Get substitution contents
Name | Type | Description |
---|---|---|
$string |
string |
Get string from token list.
Name | Type | Description |
---|---|---|
$tokens |
array |
Trigger visitor error
Emit a vistitor error, and convert it to an exception depending on the error reporting settings.
Name | Type | Description |
---|---|---|
$level |
int | |
$message |
string | |
$file |
string | |
$line |
int | |
$position |
int |
Method | Description |
---|---|
ezcDocumentErrorReporting::triggerError() |
Trigger parser error. |
Docarate RST AST
Visit the RST abstract syntax tree.
Name | Type | Description |
---|---|---|
$ast |
ezcDocumentRstDocumentNode |
Method | Description |
---|---|
ezcDocumentRstXhtmlVisitor::visit() |
Docarate RST AST |
ezcDocumentRstXhtmlBodyVisitor::visit() |
Docarate RST AST |
ezcDocumentRstDocbookVisitor::visit() |
Docarate RST AST |
Visit children
Just recurse into node and visit its children, ignoring the actual node.
Name | Type | Description |
---|---|---|
$root |
DOMNode | |
$node |
ezcDocumentRstNode |
Method | Description |
---|---|
ezcDocumentRstDocbookVisitor::visitChildren() |
Visit children |
Visit substitution reference node
Name | Type | Description |
---|---|---|
$root |
DOMNode | |
$node |
ezcDocumentRstNode |
Method | Description |
---|---|
ezcDocumentRstDocbookVisitor::visitSubstitutionReference() |
Visit substitution reference node |
Visit text node
Name | Type | Description |
---|---|---|
$root |
DOMNode | |
$node |
ezcDocumentRstNode |
Method | Description |
---|---|
ezcDocumentRstDocbookVisitor::visitText() |
Visit text node |