PHP Class Gregwar\RST\Parser

Afficher le fichier Open project: gregwar/rst Class Usage Examples

Protected Properties

Свойство Type Description
$buffer The buffer is an array containing current lines that are parsed
$currentLine Current line
$directive Current directive to be applied on next node
$directives Current directives
$document Current document
$environment Environment
$filename File name
$includeAllowed Allow include directives?
$includeRoot Behaves like PHP's open_basedir
$isCode Is the current node code ?
$lineInfo
$listFlow
$listLine
$specialLetter Current level of special lines (==== and so)
$state Current state

Méthodes publiques

Méthode Description
__construct ( $environment = null, $kernel = null )
createSpan ( $span ) : Span Create a span, which is a text with inline style
getCurrentLine ( ) Gets the current line
getDocument ( ) : Gregwar\RST\Document Get the current document
getEnvironment ( ) : Environment Get the current environment
getFilename ( ) Gets the current filename
getIncludeAllowed ( ) : boolean
getIncludeRoot ( ) : string
getKernel ( ) : Kernel Get the current kernel
getSubParser ( ) : Parser Get a parser with the same environment that this one
includeFileAllowed ( $path ) : boolean Is this file allowed to be included?
includeFiles ( $document ) Include all files described in $document and returns the new string of the given document with includes processed
initDirectives ( ) Initializing built-in directives
initReferences ( ) Initializing references
parse ( string $document ) : Gregwar\RST\Document Parse a document and return a Document instance
parseFile ( string $file ) : Gregwar\RST\Document Parses a given file and return a Document instance
parseLink ( string $line ) : boolean Try to parse a link definition
parseLocal ( string $document ) : Gregwar\RST\Document
pushListLine ( string $line, boolean $flush = false ) : boolean Push a line to the current list node buffer
registerDirective ( Gregwar\RST\Directive $directive ) Register a new directive handler
setIncludePolicy ( boolean $allow, string $directory = null ) : self Allow/disallow includes, or restrict them to a directory

Méthodes protégées

Méthode Description
directiveAddOption ( string $line ) Try to add an option line to the current directive, returns true if sucess and false if failure
findTableChars ( string $line ) : array | boolean Finding the table chars
flush ( ) Flushes the current buffer to create a node
getCurrentDirective ( ) : Gregwar\RST\Directive Gets the current directive
init ( )
initDirective ( string $line ) : false Get current directive if the buffer contains one
isBlockLine ( string $line ) : boolean A line is a code line if it's empty or if it begins with a trimable caracter, for instance:
isComment ( string $line ) : boolean Is this line a comment ?
isDirective ( string $line ) : boolean Is this line a directive ?
isListLine ( string $line ) : boolean Is the given line a list line ?
isSpecialLine ( string $line ) : boolean Tell if a line is a special separating line for title and separators, returns the depth of the special line
parseLine ( string &$line ) Process one line
parseLines ( string $document ) Process all the lines of a document string
parseListLine ( string $line ) : array Parses a list line
parseTableLine ( string $line ) : mixed If the given line is a table line, this will returns the parts of the given line, i.e the offset of the separators
prepareCode ( ) : boolean Tells if the current buffer is announcing a block of code

Method Details

__construct() public méthode

public __construct ( $environment = null, $kernel = null )

createSpan() public méthode

Create a span, which is a text with inline style
public createSpan ( $span ) : Span
$span the content string
Résultat Span a span object

directiveAddOption() protected méthode

Try to add an option line to the current directive, returns true if sucess and false if failure
protected directiveAddOption ( string $line )
$line string

findTableChars() protected méthode

Finding the table chars
protected findTableChars ( string $line ) : array | boolean
$line string
Résultat array | boolean

flush() protected méthode

Flushes the current buffer to create a node
protected flush ( )

getCurrentDirective() protected méthode

Gets the current directive
protected getCurrentDirective ( ) : Gregwar\RST\Directive
Résultat Gregwar\RST\Directive

getCurrentLine() public méthode

Gets the current line
public getCurrentLine ( )

getDocument() public méthode

Get the current document
public getDocument ( ) : Gregwar\RST\Document
Résultat Gregwar\RST\Document the document

getEnvironment() public méthode

Get the current environment
public getEnvironment ( ) : Environment
Résultat Environment the parser environment

getFilename() public méthode

Gets the current filename
public getFilename ( )

getIncludeAllowed() public méthode

public getIncludeAllowed ( ) : boolean
Résultat boolean

getIncludeRoot() public méthode

public getIncludeRoot ( ) : string
Résultat string

getKernel() public méthode

Get the current kernel
public getKernel ( ) : Kernel
Résultat Kernel the kernel

getSubParser() public méthode

Get a parser with the same environment that this one
public getSubParser ( ) : Parser
Résultat Parser a new parser with the same environment

includeFileAllowed() public méthode

Is this file allowed to be included?
public includeFileAllowed ( $path ) : boolean
$path
Résultat boolean

includeFiles() public méthode

Include all files described in $document and returns the new string of the given document with includes processed
public includeFiles ( $document )

init() protected méthode

protected init ( )

initDirective() protected méthode

.. |variable| name:: data :option: value :otherOption: otherValue
protected initDirective ( string $line ) : false
$line string
Résultat false if this is not a directive, else an array containing : - variable: the variable name of the directive - name: the directive name - data: the data of the directive - options: an array of all the options and their values

initDirectives() public méthode

Initializing built-in directives
public initDirectives ( )

initReferences() public méthode

Initializing references
public initReferences ( )

isBlockLine() protected méthode

This is a block because there is a space in the front of the caracters This is still part of the block, even if there is an empty line
protected isBlockLine ( string $line ) : boolean
$line string the line text
Résultat boolean true if the line is still in a block

isComment() protected méthode

Is this line a comment ?
protected isComment ( string $line ) : boolean
$line string the line
Résultat boolean true if it's a comment

isDirective() protected méthode

Is this line a directive ?
protected isDirective ( string $line ) : boolean
$line string the line
Résultat boolean true if it's a directive

isListLine() protected méthode

Is the given line a list line ?
protected isListLine ( string $line ) : boolean
$line string
Résultat boolean true if the given line is a list line

isSpecialLine() protected méthode

Tell if a line is a special separating line for title and separators, returns the depth of the special line
protected isSpecialLine ( string $line ) : boolean
$line string
Résultat boolean

parse() public méthode

Parse a document and return a Document instance
public parse ( string $document ) : Gregwar\RST\Document
$document string The contents (string) of the document
Résultat Gregwar\RST\Document The created document

parseFile() public méthode

Parses a given file and return a Document instance
public parseFile ( string $file ) : Gregwar\RST\Document
$file string the file name to parse
Résultat Gregwar\RST\Document $document the document instance

parseLine() protected méthode

Process one line
protected parseLine ( string &$line )
$line string the line string

parseLines() protected méthode

Process all the lines of a document string
protected parseLines ( string $document )
$document string the string (content) of the document

parseListLine() protected méthode

Parses a list line
protected parseListLine ( string $line ) : array
$line string the string line
Résultat array containing: - true if the list is ordered, false else - the depth of the list - the text of the first line without the tick

parseLocal() public méthode

public parseLocal ( string $document ) : Gregwar\RST\Document
$document string
Résultat Gregwar\RST\Document The created document

parseTableLine() protected méthode

====================== ========= =========== 0 23 33 +---------------------+---------+-----------+ 1 23 33
protected parseTableLine ( string $line ) : mixed
$line string
Résultat mixed

prepareCode() protected méthode

Tells if the current buffer is announcing a block of code
protected prepareCode ( ) : boolean
Résultat boolean

pushListLine() public méthode

Push a line to the current list node buffer
public pushListLine ( string $line, boolean $flush = false ) : boolean
$line string
$flush boolean
Résultat boolean

registerDirective() public méthode

Register a new directive handler
public registerDirective ( Gregwar\RST\Directive $directive )
$directive Gregwar\RST\Directive a directive handler

setIncludePolicy() public méthode

Allow/disallow includes, or restrict them to a directory
public setIncludePolicy ( boolean $allow, string $directory = null ) : self
$allow boolean
$directory string
Résultat self

Property Details

$buffer protected_oe property

The buffer is an array containing current lines that are parsed
protected $buffer

$currentLine protected_oe property

Current line
protected $currentLine

$directive protected_oe property

Current directive to be applied on next node
protected $directive

$directives protected_oe property

Current directives
protected $directives

$document protected_oe property

Current document
protected $document

$environment protected_oe property

Environment
protected $environment

$filename protected_oe property

File name
protected $filename

$includeAllowed protected_oe property

Allow include directives?
protected $includeAllowed

$includeRoot protected_oe property

Behaves like PHP's open_basedir
protected $includeRoot

$isCode protected_oe property

Is the current node code ?
protected $isCode

$lineInfo protected_oe property

protected $lineInfo

$listFlow protected_oe property

protected $listFlow

$listLine protected_oe property

protected $listLine

$specialLetter protected_oe property

Current level of special lines (==== and so)
protected $specialLetter

$state protected_oe property

Current state
protected $state