PHP Class League\CommonMark\Cursor

Afficher le fichier Open project: colinodell/commonmark-php Class Usage Examples

Méthodes publiques

Méthode 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 méthode

public __construct ( string $line )
$line string

advance() public méthode

Move the cursor forwards
public advance ( )

advanceBy() public méthode

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

advanceBySpaceOrTab() public méthode

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

advanceToEnd() public méthode

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

advanceToFirstNonSpace() public méthode

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

advanceWhileMatches() public méthode

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
Résultat integer Number of positions moved (0 if unsuccessful)

getCharacter() public méthode

public getCharacter ( integer | null $index = null ) : string | null
$index integer | null
Résultat string | null

getColumn() public méthode

public getColumn ( ) : integer
Résultat integer

getFirstNonSpaceCharacter() public méthode

Returns the next character which isn't a space
public getFirstNonSpaceCharacter ( ) : string
Résultat string

getFirstNonSpacePosition() public méthode

Returns the position of the next non-space character
public getFirstNonSpacePosition ( ) : integer
Résultat integer

getIndent() public méthode

Calculates the current indent (number of spaces after current position)
public getIndent ( ) : integer
Résultat integer

getLine() public méthode

public getLine ( ) : string
Résultat string

getPosition() public méthode

public getPosition ( ) : integer
Résultat integer

getPreviousText() public méthode

public getPreviousText ( ) : string
Résultat string

getRemainder() public méthode

public getRemainder ( ) : string
Résultat string

isAtEnd() public méthode

public isAtEnd ( ) : boolean
Résultat boolean

isBlank() public méthode

Whether the remainder is blank
public isBlank ( ) : boolean
Résultat boolean

isIndented() public méthode

Whether the cursor is indented to INDENT_LEVEL
public isIndented ( ) : boolean
Résultat boolean

match() public méthode

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

peek() public méthode

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

restoreState() public méthode

public restoreState ( CursorState $state )
$state CursorState

saveState() public méthode

public saveState ( ) : CursorState
Résultat CursorState