class League / CommonMark / Parser / Cursor
You are viewing an older version of the documentation. For the latest, please visit 2.4 documentation.

Cursor

Constants

public

INDENT_LEVEL

Default: 4

Properties

private

$line

Default: null
private

$length

Default: null
private

$currentPosition int

<p>It's possible for this to be 1 char past the end, meaning we've parsed all chars and have reached the end. In this state, any character-returning method MUST return null.</p>

private

$column

private

$indent

private

$previousPosition

private

$nextNonSpaceCache

Default: null
private

$partiallyConsumedTab

Default: false
private

$lineContainsTabs

Default: null
private

$isMultibyte

Default: null
private

$charCache array

Default: []

Methods

public

__construct ( string $line ) : void

Parameters

  • $line string
    The line being parsed (ASCII or UTF-8)
public

getNextNonSpacePosition ( ) : void

Returns the position of the next character which is not a space (or tab)

public

getNextNonSpaceCharacter ( ) : void

Returns the next character which isn't a space (or tab)

public

getIndent ( ) : void

Calculates the current indent (number of spaces after current position)

public

isIndented ( ) : void

Whether the cursor is indented to INDENT_LEVEL

public

getCharacter ( int $index ) : void

public

getCurrentCharacter ( ) : void

Slightly-optimized version of getCurrent(null)

public

peek ( int $offset ) : void

Returns the next character (or null, if none) without advancing forwards

public

isBlank ( ) : void

Whether the remainder is blank

public

advance ( ) : void

Move the cursor forwards

public

advanceBy ( int $characters , bool $advanceByColumns ) : void

Move the cursor forwards

Parameters

  • $characters int
    Number of characters to advance by
  • $advanceByColumns bool
    Whether to advance by columns instead of spaces
private

advanceWithoutTabCharacters ( int $characters ) : void

public

advanceBySpaceOrTab ( ) : void

Advances the cursor by a single space or tab, if present

public

advanceToNextNonSpaceOrTab ( ) : int

Parse zero or more space/tab characters

public

advanceToNextNonSpaceOrNewline ( ) : int

Parse zero or more space characters, including at most one newline.

public

advanceToEnd ( ) : int

Move the position to the very end of the line

public

getRemainder ( ) : void

public

getLine ( ) : void

public

isAtEnd ( ) : void

public

match ( string $regex ) : void

Try to match a regular expression

public

saveState ( ) : void

Encapsulates the current state of this cursor in case you need to rollback later.

public

restoreState ( CursorState $state ) : void

Restore the cursor to a previous state.

public

getPosition ( ) : void

public

getPreviousText ( ) : void

public

getSubstring ( int $start , int $length ) : void

public

getColumn ( ) : void