League\CommonMark\Cursor::advanceToEnd PHP Method

advanceToEnd() public method

Move the position to the very end of the line
public advanceToEnd ( ) : integer
return integer The number of characters moved
    public function advanceToEnd()
    {
        $this->previousPosition = $this->currentPosition;
        $this->firstNonSpaceCache = null;
        $this->currentPosition = $this->length;
        return $this->currentPosition - $this->previousPosition;
    }

Usage Example

 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->isIndented()) {
         return false;
     }
     $match = RegexHelper::matchAt(RegexHelper::getInstance()->getThematicBreakRegex(), $cursor->getLine(), $cursor->getFirstNonSpacePosition());
     if ($match === null) {
         return false;
     }
     // Advance to the end of the string, consuming the entire line (of the thematic break)
     $cursor->advanceToEnd();
     $context->addBlock(new ThematicBreak());
     $context->setBlocksParsed(true);
     return true;
 }