PHP Class League\CommonMark\Cursor

Datei anzeigen Open project: colinodell/commonmark-php Class Usage Examples

Public Methods

Method Description
__construct ( string $line )
advance ( ) Move the cursor forwards
advanceBy ( integer $characters, $advanceByColumns = false ) Move the cursor forwards
advanceBySpaceOrTab ( ) : boolean Advances the cursor by a single space or tab, if present
advanceToEnd ( ) : integer Move the position to the very end of the line
advanceToFirstNonSpace ( ) : integer Parse zero or more space characters, including at most one newline
advanceWhileMatches ( string $character, integer | null $maximumCharactersToAdvance = null ) : integer Advances the cursor while the given character is matched
getCharacter ( integer | null $index = null ) : string | null
getColumn ( ) : integer
getFirstNonSpaceCharacter ( ) : string Returns the next character which isn't a space
getFirstNonSpacePosition ( ) : integer Returns the position of the next non-space character
getIndent ( ) : integer Calculates the current indent (number of spaces after current position)
getLine ( ) : string
getPosition ( ) : integer
getPreviousText ( ) : string
getRemainder ( ) : string
isAtEnd ( ) : boolean
isBlank ( ) : boolean Whether the remainder is blank
isIndented ( ) : boolean Whether the cursor is indented to INDENT_LEVEL
match ( string $regex ) : string | null Try to match a regular expression
peek ( integer $offset = 1 ) : string | null Returns the next character (or null, if none) without advancing forwards
restoreState ( CursorState $state )
saveState ( ) : CursorState

Method Details

__construct() public method

public __construct ( string $line )
$line string

advance() public method

Move the cursor forwards
public advance ( )

advanceBy() public method

Move the cursor forwards
public advanceBy ( integer $characters, $advanceByColumns = false )
$characters integer Number of characters to advance by

advanceBySpaceOrTab() public method

Advances the cursor by a single space or tab, if present
public advanceBySpaceOrTab ( ) : boolean
return boolean

advanceToEnd() public method

Move the position to the very end of the line
public advanceToEnd ( ) : integer
return integer The number of characters moved

advanceToFirstNonSpace() public method

Parse zero or more space characters, including at most one newline
public advanceToFirstNonSpace ( ) : integer
return integer Number of positions moved

advanceWhileMatches() public method

Advances the cursor while the given character is matched
public advanceWhileMatches ( string $character, integer | null $maximumCharactersToAdvance = null ) : integer
$character string Character to match
$maximumCharactersToAdvance integer | null Maximum number of characters to advance before giving up
return integer Number of positions moved (0 if unsuccessful)

getCharacter() public method

public getCharacter ( integer | null $index = null ) : string | null
$index integer | null
return string | null

getColumn() public method

public getColumn ( ) : integer
return integer

getFirstNonSpaceCharacter() public method

Returns the next character which isn't a space

getFirstNonSpacePosition() public method

Returns the position of the next non-space character

getIndent() public method

Calculates the current indent (number of spaces after current position)
public getIndent ( ) : integer
return integer

getLine() public method

public getLine ( ) : string
return string

getPosition() public method

public getPosition ( ) : integer
return integer

getPreviousText() public method

public getPreviousText ( ) : string
return string

getRemainder() public method

public getRemainder ( ) : string
return string

isAtEnd() public method

public isAtEnd ( ) : boolean
return boolean

isBlank() public method

Whether the remainder is blank
public isBlank ( ) : boolean
return boolean

isIndented() public method

Whether the cursor is indented to INDENT_LEVEL
public isIndented ( ) : boolean
return boolean

match() public method

Returns the matching text and advances to the end of that match
public match ( string $regex ) : string | null
$regex string
return string | null

peek() public method

Returns the next character (or null, if none) without advancing forwards
public peek ( integer $offset = 1 ) : string | null
$offset integer
return string | null

restoreState() public method

public restoreState ( CursorState $state )
$state CursorState

saveState() public method

public saveState ( ) : CursorState
return CursorState