Path

ez components / documentation / api reference / 2009.1 / document


eZ Components 2009.1

Document: ezcDocumentRstParser

[ Tutorial ] [ Conversion ] [ Styles ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcDocumentRstParser

Parser for RST documents [source]
RST is not describable by a context free grammar, so that the common parser approaches won't work.
Parser basics -------------
We decided to implement a parser roughly following the scheme of common shift reduce parsers with a dynamic lookahead.
  • Shifting:
The shift step commonly tries to convert a token or a sequence of tokens to the respective AST node. In the case of RST we may need a dynamic lookahead to decide which type of AST node a token relates to, which is different from common LRn parsers.
There is a map of parser tokens to internal methods for callbacks, which are called in the defined order if the main parser methods reach the respective token in the provided token array. Each shift method is called with the relating token and the array of subsequent, yet unhandled, tokens.
These methods are expected to return either false, if the current token cannot be shifted by the called rule, true, when the token has been handled, but no document node has been created from it or a new ezcDocumentRstNode object, which is some AST node. When a shift method returned false the next shift method in the array is called to handle the token.
The returned ezcDocumentRstNode objects are put on the document stack in the order they are found in the token array.
  • Reducing:
The reduce step commonly tries to reduce matching structures, like finding the matching opening brace, when a closing brace has been added to the document stack. In this case all nodes between the two braces are aggregated into the brace node, so that a tree is created.
The reductions array defines an array with a mapping of node types to rection callbacks, which are called if such a node has been added to the document stack. Each reduction method may either return false, if it could not handle the given node, or a new node. The reduction methods often manipulate the document stack, like searching backwards and aggregating nodes.
If a reduction method returns a node the parser reenters the reduction process with the new node.
The state of the RST parser heavily depends on the current indentation level, which is stored in the class property $indentation, and mainly modified in the special shift method updateIndentation(), which is called on each line break token.
Some of the shift methods aggregate additional tokens from the token array, bypassing the main parser method. This should only be done, if no common handling is required for the aggregated tokens.
Tables ------
The handling of RST tables is quite complex and the affiliation of tokens to nodes depend on the line and character position of the token. In this case the tokens are first aggregated into their cell contexts and reenter the parser afterwards.
For token lists, which are required to reenter the parser - independently from the current global parser state - the method reenterParser() takes such token lists, removes the overall indentation and returns a new document of the provided token array.

Parents

ezcDocumentParser
   |
   --ezcDocumentRstParser

Constants

REGEXP_INLINE_LINK = '(
(?:^|[\s,.!?])
(?# Ignore matching braces around the URL)
(<)?
(\[)?
(\()?
(?# Ignore quoting around the URL)
([\'"]?)
(?# Actually match the URL)
(?P<match>
(?P<url>[a-z]+://[^\s]*?) |
(?:mailto:)?(?P<mail>[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})
)
\4
(?(3)\))
(?(2)\])
(?(1)>)
(?# Ignore common punctuation after the URL)
[.,?!]?(?:\s|$)
)xm'
PCRE regular expression for detection of URLs in texts.

Member Variables

protected array $blockNodes = array(
ezcDocumentRstNode::PARAGRAPH,
ezcDocumentRstNode::BLOCKQUOTE,
ezcDocumentRstNode::SECTION,
ezcDocumentRstNode::BULLET_LIST,
ezcDocumentRstNode::ENUMERATED_LIST,
ezcDocumentRstNode::TABLE,
ezcDocumentRstNode::LITERAL_BLOCK,
ezcDocumentRstNode::COMMENT,
ezcDocumentRstNode::DIRECTIVE,
ezcDocumentRstNode::SUBSTITUTION,
ezcDocumentRstNode::NAMED_REFERENCE,
ezcDocumentRstNode::FOOTNOTE,
ezcDocumentRstNode::ANON_REFERENCE,
ezcDocumentRstNode::TRANSITION,
ezcDocumentRstNode::FIELD_LIST,
ezcDocumentRstNode::DEFINITION_LIST,
ezcDocumentRstNode::LINE_BLOCK,
)

List of node types, which are valid block nodes, where we can indentation changes after, or which can be aggregated into sections.
protected array $documentStack = array()
Contains a list of detected syntax elements.

At the end of a successfull parsing process this should only contain one document syntax element. During the process it may contain a list of elements, which are up to reduction.
Each element in the stack has to be an object extending from ezcDocumentRstNode, which may again contain any amount such objects. This way an abstract syntax tree is constructed.
protected int $indentation = 0
Current indentation of a paragraph / lsit item.
protected int $postIndentation = null
For the special case of dense bullet lists we need to update the indetation right after we created a new paragraph in one action. We store the indetation to update past the paragraph creation in this case in this variable.
protected array $reductions = array(
// Also for ezcDocumentRstNode::SECTION, since the constants point to
// the same value.
ezcDocumentRstNode::DOCUMENT => array(
'reduceList',
'reduceSection',
),ezcDocumentRstNode::TITLE=>array('reduceTitle',),ezcDocumentRstNode::PARAGRAPH=>array('reduceParagraph','reduceListItem','reduceBlockquoteAnnotationParagraph','reduceBlockquote',),ezcDocumentRstNode::COMMENT=>array('reduceListItem',),ezcDocumentRstNode::DIRECTIVE=>array('reduceListItem',),ezcDocumentRstNode::LITERAL_BLOCK=>array('reduceListItem',),ezcDocumentRstNode::BULLET_LIST=>array('reduceList',),ezcDocumentRstNode::ENUMERATED_LIST=>array('reduceList',),ezcDocumentRstNode::ANNOTATION=>array('reduceBlockquoteAnnotation',),ezcDocumentRstNode::MARKUP_EMPHASIS=>array('reduceMarkup',),ezcDocumentRstNode::MARKUP_STRONG=>array('reduceMarkup',),ezcDocumentRstNode::MARKUP_INTERPRETED=>array('reduceInterpretedText','reduceInternalTarget',),ezcDocumentRstNode::MARKUP_SUBSTITUTION=>array('reduceMarkup',),ezcDocumentRstNode::REFERENCE=>array('reduceReference',),ezcDocumentRstNode::LINK_ANONYMOUS=>array('reduceLink',),ezcDocumentRstNode::LINK_REFERENCE=>array('reduceLink',),)

Array containing simplified reduce ruleset

We cannot express the RST syntax as a usual grammar using a BNF. This structure implements a pseudo grammar by assigning a number of callbacks for internal methods implementing reduction rules for a detected syntax element.
1.   array(
2.       ezcDocumentRstNode::DOCUMENT => 'reduceDocument'
3.       ...
4.   )
protected array $shifts = array(
ezcDocumentRstToken::WHITESPACE => array(

// This should always be the last rule in this section: We shift
// the whitespace, which could not be recognized as something else,
// as text.
'shiftWhitespaceAsText',
),ezcDocumentRstToken::NEWLINE=>array('shiftParagraph','updateIndentation','shiftAsWhitespace',),ezcDocumentRstToken::BACKSLASH=>array('shiftBackslash',),ezcDocumentRstToken::SPECIAL_CHARS=>array('shiftTitle','shiftTransition','shiftLineBlock','shiftInlineLiteral','shiftInlineMarkup','shiftInterpretedTextMarkup','shiftReference','shiftAnonymousHyperlinks','shiftExternalReference','shiftBlockquoteAnnotation','shiftBulletList','shiftEnumeratedList','shiftLiteralBlock','shiftComment','shiftAnonymousReference','shiftFieldList','shiftSimpleTable','shiftGridTable',// This should always be the last rule in this section: We shift
// special character groups, which could not be recognized as
// something else, as text.
'shiftSpecialCharsAsText',),ezcDocumentRstToken::TEXT_LINE=>array('shiftEnumeratedList','shiftText',),ezcDocumentRstToken::EOF=>array('shiftDocument',),)

Array containing simplified shift ruleset

We cannot express the RST syntax as a usual grammar using a BNF. With the pumping lemma for context free grammars [1] you can easily prove, that the word a^n b c^n d e^n is not a context free grammar, and this is what the title definitions are.
This structure contains an array with callbacks implementing the shift rules for all tokens. There may be multiple rules for one single token.
The callbacks itself create syntax elements and push them to the document stack. After each push the reduction callbacks will be called for the pushed elements.
The array should look like:
1.   array(
2.       WHITESPACE => array(
3.           reductionMethod,
4.           ...
5.       ),
6.       ...
7.   )
[1] http://en.wikipedia.org/wiki/Pumping_lemma_for_context-free_languages
protected array $shortDirectives = array(
'note',
'notice',
'warning',
'danger',
'image',
)

List of builtin directives, which do not aggregate more text the parameters and options. User defined directives always aggregate following indeted text.
protected array $textNodes = array(
ezcDocumentRstNode::TEXT_LINE,
ezcDocumentRstNode::MARKUP_EMPHASIS,
ezcDocumentRstNode::MARKUP_STRONG,
ezcDocumentRstNode::MARKUP_INTERPRETED,
ezcDocumentRstNode::MARKUP_LITERAL,
ezcDocumentRstNode::MARKUP_SUBSTITUTION,
ezcDocumentRstNode::LINK_ANONYMOUS,
ezcDocumentRstNode::LINK_REFERENCE,
ezcDocumentRstNode::REFERENCE,
ezcDocumentRstNode::TARGET,
)

List of node types, which can be considered as inline text nodes.
protected array $titleLevels = array()
Array with title levels used by the document author in their order.

Inherited Member Variables

From ezcDocumentParser:
protected  ezcDocumentParser::$options
protected  ezcDocumentParser::$properties

Method Summary

protected void detectFootnoteType( $name )
Tries to detect footnote type
protected void dumpDocumentStack( )
Print a dump of the document stack
protected ezcDocumentRstSubstitutionNode handleSpecialDirectives( $substitution, $node )
Handle special directives
protected bool isEnumeratedList( $tokens )
Is enumerated list?
protected boolean isInlineEndToken( $token, &$tokens, $tokens )
Check if token is an inline markup end token.
protected boolean isInlineStartToken( $token, &$tokens, $tokens )
Check if token is an inline markup start token.
public void parse( $tokens )
Shift- / reduce-parser for RST token stack
protected array readGridTableSpecification( &$tokens, $tokens )
Read grid table specifications
protected array readMutlipleIndentedLines( &$tokens, [$strict = false], $tokens )
Read multiple lines
protected array readSimpleCells( $cellStarts, &$tokens, $tokens )
Read simple cells
protected array readSimpleTableSpecification( &$tokens, $tokens )
Read simple table specifications
protected array readUntil( &$tokens, $until, $tokens )
Read all token until one of the given tokens occurs
protected void reduceBlockquote( $node )
Reduce paragraph to blockquote
protected void reduceBlockquoteAnnotation( $node )
Reduce blockquote annotation
protected void reduceBlockquoteAnnotationParagraph( $node )
Reduce blockquote annotation content
protected void reduceInternalTarget( $node )
Reduce internal target
protected void reduceInterpretedText( $node )
Reduce interpreted text inline markup
protected void reduceLink( $node )
Reduce link
protected void reduceList( $node )
Reduce item to bullet list
protected void reduceListItem( $node )
Reduce paragraph to bullet lsit
protected void reduceMarkup( $node )
Reduce markup
protected void reduceParagraph( $node )
Reduce paragraph
protected void reduceReference( $node )
Reduce reference
protected void reduceSection( $node )
Reduce prior sections, if a new section has been found.
protected void reduceTitle( $node )
Reduce all elements to one document node.
protected ezcDocumentRstDocumentNode reenterParser( $tokens, [$reindent = true] )
Reenter parser with a list of tokens
protected ezcDocumentRstMarkupEmphasisNode shiftAnonymousHyperlinks( $token, &$tokens, $tokens )
Detect inline markup
protected ezcDocumentRstMarkupEmphasisNode shiftAnonymousReference( $token, &$tokens, $tokens )
Shift anonymous reference target
protected ezcDocumentRstTextLineNode shiftAsWhitespace( $token, &$tokens, $tokens )
Keep the newline as a single whitespace to maintain readability in texts.
protected ezcDocumentRstTitleNode shiftBackslash( $token, &$tokens, $tokens )
Escaping of special characters
protected ezcDocumentRstMarkupEmphasisNode shiftBlockquoteAnnotation( $token, &$tokens, $tokens )
Blockquote annotations
protected ezcDocumentRstMarkupEmphasisNode shiftBulletList( $token, &$tokens, $tokens )
Bullet point lists
protected ezcDocumentRstMarkupEmphasisNode shiftComment( $token, &$tokens, $tokens )
Shift comment
protected ezcDocumentRstMarkupEmphasisNode shiftDefinitionList( $token, &$tokens, $tokens )
Shift definition lists
protected ezcDocumentRstDirectiveNode shiftDirective( $directive, &$tokens, $tokens )
Shift directives
protected ezcDocumentRstDocumentNode shiftDocument( $token, &$tokens, $tokens )
Create new document node
protected ezcDocumentRstMarkupEmphasisNode shiftEnumeratedList( $token, &$tokens, $tokens )
Enumerated lists
protected ezcDocumentRstMarkupEmphasisNode shiftExternalReference( $token, &$tokens, $tokens )
Detect inline markup
protected ezcDocumentRstMarkupEmphasisNode shiftFieldList( $token, &$tokens, $tokens )
Shift field lists
protected ezcDocumentRstMarkupEmphasisNode shiftGridTable( $token, &$tokens, $tokens )
Shift grid table
protected ezcDocumentRstMarkupEmphasisNode shiftInlineLiteral( $token, &$tokens, $tokens )
Detect inline literal
protected ezcDocumentRstMarkupEmphasisNode shiftInlineMarkup( $token, &$tokens, $tokens )
Detect inline markup
protected ezcDocumentRstMarkupEmphasisNode shiftInterpretedTextMarkup( $token, &$tokens, $tokens )
Detect interpreted text inline markup
protected mixed shiftInterpretedTextRole( $token, &$tokens, $tokens )
Try to shift a interpreted text role
protected ezcDocumentRstTitleNode shiftLineBlock( $token, &$tokens, $tokens )
Shift line blocks
protected ezcDocumentRstMarkupEmphasisNode shiftLiteralBlock( $token, &$tokens, $tokens )
Shift literal block
protected ezcDocumentRstTitleNode shiftParagraph( $token, &$tokens, $tokens )
Shift a paragraph node on two newlines
protected ezcDocumentRstMarkupEmphasisNode shiftReference( $token, &$tokens, $tokens )
Detect reference
protected ezcDocumentRstMarkupEmphasisNode shiftSimpleTable( $token, &$tokens, $tokens )
Shift simple table
protected ezcDocumentRstTextLineNode shiftSpecialCharsAsText( $token, &$tokens, $tokens )
Just keep text as text nodes
protected ezcDocumentRstTitleNode shiftText( $token, &$tokens, $tokens )
Just keep text as text nodes
protected ezcDocumentRstTitleNode shiftTitle( $token, &$tokens, $tokens )
Create new title node from titles with a top and bottom line
protected ezcDocumentRstTitleNode shiftTransition( $token, &$tokens, $tokens )
Shift transistions, which are separators in the document.
protected ezcDocumentRstTextLineNode shiftWhitespaceAsText( $token, &$tokens, $tokens )
Just keep text as text nodes
protected bool updateIndentation( $token, &$tokens, $tokens )
Update the current indentation after each newline.

Inherited Methods

From ezcDocumentParser :
public ezcDocumentParser ezcDocumentParser::__construct()
Construct new document
public array ezcDocumentParser::getErrors()
Return list of errors occured during visiting the document.
public void ezcDocumentParser::triggerError()
Trigger parser error

Methods

detectFootnoteType

void detectFootnoteType( $name )
Tries to detect footnote type
The type of the footnote

Parameters

Name Type Description
$name array  

dumpDocumentStack

void dumpDocumentStack( )
Print a dump of the document stack
This function is only for use during dubbing of the document stack structure.

handleSpecialDirectives

ezcDocumentRstSubstitutionNode handleSpecialDirectives( $substitution, $node )
Handle special directives
Handle special directives like replace, which require reparsing of the directives contents, which is not possible to do during visiting, but is required to already be done inside the parser.

Parameters

Name Type Description
$substitution ezcDocumentRstSubstitutionNode  
$node ezcDocumentRstDirectiveNode  

isEnumeratedList

bool isEnumeratedList( $tokens )
Is enumerated list?
As defined at http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#bullet-lists
Checks if the curretn token with thw following tokens may be an enumerated list. Used by the repective shifting method and when checking for indentation updates.
Returns true, if the tokens may be an enumerated list, and false otherwise.

Parameters

Name Type Description
$tokens array  

isInlineEndToken

boolean isInlineEndToken( ezcDocumentRstToken $token, &$tokens, array $tokens )
Check if token is an inline markup end token.
For a user readable list of the following rules, see: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

isInlineStartToken

boolean isInlineStartToken( ezcDocumentRstToken $token, &$tokens, array $tokens )
Check if token is an inline markup start token.
For a user readable list of the following rules, see: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

parse

void parse( $tokens )
Shift- / reduce-parser for RST token stack

Parameters

Name Type Description
$tokens array  

readGridTableSpecification

array readGridTableSpecification( &$tokens, array $tokens )
Read grid table specifications
Read the column specification headers of a grid table and return the sizes of the specified columns in an array.

Parameters

Name Type Description
$tokens array  
&$tokens  

readMutlipleIndentedLines

array readMutlipleIndentedLines( &$tokens, [bool $strict = false], array $tokens )
Read multiple lines
Reads the content of multiple indented lines, where the indentation can bei either handled strict, or lose, when literal text is expected.
Returns an array with the collected tokens, until the indentation changes.

Parameters

Name Type Description
$tokens array  
$strict bool  
&$tokens array  

readSimpleCells

array readSimpleCells( array $cellStarts, &$tokens, array $tokens )
Read simple cells
Read cells as defined in simple tables. Cells are maily structured by whitespaces, but may also exceed one cell.
Returns an array with cells, ordered by their rows and columns.

Parameters

Name Type Description
$cellStarts array  
$tokens array  
&$tokens  

readSimpleTableSpecification

array readSimpleTableSpecification( &$tokens, array $tokens )
Read simple table specifications
Read the column specification headers of a simple table and return the sizes of the specified columns in an array.

Parameters

Name Type Description
$tokens array  
&$tokens  

readUntil

array readUntil( &$tokens, $until, array $tokens )
Read all token until one of the given tokens occurs
Reads all tokens and removes them from the token stack, which do not match of the given tokens. Escaping is maintained.

Parameters

Name Type Description
$tokens array  
$until array  
&$tokens array  

reduceBlockquote

void reduceBlockquote( ezcDocumentRstNode $node )
Reduce paragraph to blockquote
Indented paragraphs are blockquotes, which should be wrapped in such a node.

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceBlockquoteAnnotation

void reduceBlockquoteAnnotation( ezcDocumentRstNode $node )
Reduce blockquote annotation

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceBlockquoteAnnotationParagraph

void reduceBlockquoteAnnotationParagraph( ezcDocumentRstNode $node )
Reduce blockquote annotation content

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceInternalTarget

void reduceInternalTarget( ezcDocumentRstNode $node )
Reduce internal target
Internal targets are listed before the literal markup block, so it may be found and reduced after we found a markup block.

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceInterpretedText

void reduceInterpretedText( ezcDocumentRstNode $node )
Reduce interpreted text inline markup
Tries to find the opening tag for a markup definition.

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceLink

void reduceLink( ezcDocumentRstNode $node )
Reduce link
Uses the preceding element as the hyperlink content. This should be either a literal markup section, or just the last word.
As we do not get workd content out of the tokenizer (too much overhead), we split out the previous text node up, in case we got one.

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceList

void reduceList( ezcDocumentRstNode $node )
Reduce item to bullet list
Called for all items, which may be part of bullet lists. Depending on the indentation level we reduce some amount of items to a bullet list.

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceListItem

void reduceListItem( ezcDocumentRstNode $node )
Reduce paragraph to bullet lsit
Indented paragraphs are bllet lists, if prefixed by a bullet list indicator.

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceMarkup

void reduceMarkup( ezcDocumentRstNode $node )
Reduce markup
Tries to find the opening tag for a markup definition.

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceParagraph

void reduceParagraph( ezcDocumentRstNode $node )
Reduce paragraph
Aggregates all nodes which are allowed as subnodes into a paragraph.

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceReference

void reduceReference( ezcDocumentRstNode $node )
Reduce reference
Reduce references as defined at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceSection

void reduceSection( ezcDocumentRstNode $node )
Reduce prior sections, if a new section has been found.
If a new section has been found all sections with a higher depth level can be closed, and all items fitting into sections may be aggregated by the respective sections as well.

Parameters

Name Type Description
$node ezcDocumentRstNode  

reduceTitle

void reduceTitle( $node )
Reduce all elements to one document node.

Parameters

Name Type Description
$node ezcDocumentRstTitleNode  

reenterParser

ezcDocumentRstDocumentNode reenterParser( $tokens, [bool $reindent = true] )
Reenter parser with a list of tokens
Returns a parsed document created from the given tokens. With optional, but default, reindetation of the tokens relative to the first token.

Parameters

Name Type Description
$tokens array  
$reindent bool  

shiftAnonymousHyperlinks

ezcDocumentRstMarkupEmphasisNode shiftAnonymousHyperlinks( ezcDocumentRstToken $token, &$tokens, array $tokens )
Detect inline markup
As defined at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftAnonymousReference

ezcDocumentRstMarkupEmphasisNode shiftAnonymousReference( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift anonymous reference target
Shift the short version of anonymous reference targets, the long version is handled in the shiftComment() method. Both are specified at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#anonymous-hyperlinks

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftAsWhitespace

ezcDocumentRstTextLineNode shiftAsWhitespace( ezcDocumentRstToken $token, &$tokens, array $tokens )
Keep the newline as a single whitespace to maintain readability in texts.

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftBackslash

ezcDocumentRstTitleNode shiftBackslash( ezcDocumentRstToken $token, &$tokens, array $tokens )
Escaping of special characters
A backslash is used for character escaping, as defined at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#escaping-mechanism

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftBlockquoteAnnotation

ezcDocumentRstMarkupEmphasisNode shiftBlockquoteAnnotation( ezcDocumentRstToken $token, &$tokens, array $tokens )
Blockquote annotations

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftBulletList

ezcDocumentRstMarkupEmphasisNode shiftBulletList( ezcDocumentRstToken $token, &$tokens, array $tokens )
Bullet point lists
As defined at http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#bullet-lists

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftComment

ezcDocumentRstMarkupEmphasisNode shiftComment( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift comment
Shift comments. Comments are introduced by '..' and just contain text. There are several other block, which are introduced the same way, but where the first token determines the actual type.
This method implements the parsing and detection of those different items.
Comments are basically described here, but there are crosscutting concerns throughout the complete specification: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#comments

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftDefinitionList

ezcDocumentRstMarkupEmphasisNode shiftDefinitionList( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift definition lists
Shift definition lists, which are introduced by an indentation change without speration by a paragraph. Because of this the method is called form the updateIndentation method, which handles such indentation changes.
The text for the definition and its classifiers is already on the document stack because of this.
Definition lists are specified at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#definition-lists

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftDirective

ezcDocumentRstDirectiveNode shiftDirective( $directive, &$tokens, array $tokens )
Shift directives
Shift directives as a subaction of the shiftComment method, though the signature differs from the common shift methods.
This method aggregated options and parameters of directives, but leaves the content aggregation to the common comment aggregation.

Parameters

Name Type Description
$directive ezcDocumentRstDirectiveNode  
$tokens array  
&$tokens array  

shiftDocument

ezcDocumentRstDocumentNode shiftDocument( ezcDocumentRstToken $token, &$tokens, array $tokens )
Create new document node

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftEnumeratedList

ezcDocumentRstMarkupEmphasisNode shiftEnumeratedList( ezcDocumentRstToken $token, &$tokens, array $tokens )
Enumerated lists
As defined at http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#bullet-lists

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftExternalReference

ezcDocumentRstMarkupEmphasisNode shiftExternalReference( ezcDocumentRstToken $token, &$tokens, array $tokens )
Detect inline markup
As defined at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftFieldList

ezcDocumentRstMarkupEmphasisNode shiftFieldList( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift field lists
Shift field lists, which are introduced by a term surrounded by columns and any text following. Field lists are specified at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#field-lists

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftGridTable

ezcDocumentRstMarkupEmphasisNode shiftGridTable( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift grid table
In "Grid tables" the values are embedded in a complete grid visually describing a a table using characters. http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-tables

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftInlineLiteral

ezcDocumentRstMarkupEmphasisNode shiftInlineLiteral( ezcDocumentRstToken $token, &$tokens, array $tokens )
Detect inline literal
As defined at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-literals

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftInlineMarkup

ezcDocumentRstMarkupEmphasisNode shiftInlineMarkup( ezcDocumentRstToken $token, &$tokens, array $tokens )
Detect inline markup
As defined at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftInterpretedTextMarkup

ezcDocumentRstMarkupEmphasisNode shiftInterpretedTextMarkup( ezcDocumentRstToken $token, &$tokens, array $tokens )
Detect interpreted text inline markup
As defined at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#interpreted-text

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftInterpretedTextRole

mixed shiftInterpretedTextRole( ezcDocumentRstToken $token, &$tokens, array $tokens )
Try to shift a interpreted text role
Text role shifting is only called directly from the shiftInterpretedTextMarkup() method and tries to find the associated role.

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftLineBlock

ezcDocumentRstTitleNode shiftLineBlock( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift line blocks
Shift line blocks, which are specified at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#line-blocks

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftLiteralBlock

ezcDocumentRstMarkupEmphasisNode shiftLiteralBlock( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift literal block
Shift a complete literal block into one node. The behaviour of literal blocks is defined at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#literal-blocks

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftParagraph

ezcDocumentRstTitleNode shiftParagraph( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift a paragraph node on two newlines

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftReference

ezcDocumentRstMarkupEmphasisNode shiftReference( ezcDocumentRstToken $token, &$tokens, array $tokens )
Detect reference
As defined at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftSimpleTable

ezcDocumentRstMarkupEmphasisNode shiftSimpleTable( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift simple table
"Simple tables" are not defined by a complete grid, but only by top and bottome lines. There exact specification can be found at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#simple-tables

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftSpecialCharsAsText

ezcDocumentRstTextLineNode shiftSpecialCharsAsText( ezcDocumentRstToken $token, &$tokens, array $tokens )
Just keep text as text nodes

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftText

ezcDocumentRstTitleNode shiftText( ezcDocumentRstToken $token, &$tokens, array $tokens )
Just keep text as text nodes

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftTitle

ezcDocumentRstTitleNode shiftTitle( ezcDocumentRstToken $token, &$tokens, array $tokens )
Create new title node from titles with a top and bottom line

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftTransition

ezcDocumentRstTitleNode shiftTransition( ezcDocumentRstToken $token, &$tokens, array $tokens )
Shift transistions, which are separators in the document.
Transitions are specified here: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#transitions

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

shiftWhitespaceAsText

ezcDocumentRstTextLineNode shiftWhitespaceAsText( ezcDocumentRstToken $token, &$tokens, array $tokens )
Just keep text as text nodes

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

updateIndentation

bool updateIndentation( ezcDocumentRstToken $token, &$tokens, array $tokens )
Update the current indentation after each newline.

Parameters

Name Type Description
$token ezcDocumentRstToken  
$tokens array  
&$tokens array  

Last updated: Mon, 29 Jun 2009