Lines Matching refs:cursor
31 public static function parseLinkDestination(Cursor $cursor): ?string
33 if ($res = $cursor->match(RegexHelper::REGEX_LINK_DESTINATION_BRACES)) {
40 if ($cursor->getCurrentCharacter() === '<') {
44 $destination = self::manuallyParseLinkDestination($cursor);
54 public static function parseLinkLabel(Cursor $cursor): int
56 $match = $cursor->match('/^\[(?:[^\\\\\[\]]|\\\\.){0,1000}\]/');
70 public static function parsePartialLinkLabel(Cursor $cursor): ?string
72 return $cursor->match('/^(?:[^\\\\\[\]]+|\\\\.?)*/');
80 public static function parseLinkTitle(Cursor $cursor): ?string
82 if ($title = $cursor->match('/' . RegexHelper::PARTIAL_LINK_TITLE . '/')) {
90 public static function parsePartialLinkTitle(Cursor $cursor, string $endDelimiter): ?string
94 if (($partialTitle = $cursor->match($regex)) === null) {
101 private static function manuallyParseLinkDestination(Cursor $cursor): ?string
103 $oldPosition = $cursor->getPosition();
104 $oldState = $cursor->saveState();
107 while (($c = $cursor->getCurrentCharacter()) !== null) {
108 if ($c === '\\' && ($peek = $cursor->peek()) !== null && RegexHelper::isEscapable($peek)) {
109 $cursor->advanceBy(2);
111 $cursor->advanceBy(1);
118 $cursor->advanceBy(1);
123 $cursor->advanceBy(1);
131 if ($cursor->getPosition() === $oldPosition && (! isset($c) || $c !== ')')) {
135 $newPos = $cursor->getPosition();
136 $cursor->restoreState($oldState);
138 $cursor->advanceBy($newPos - $cursor->getPosition());
140 return $cursor->getPreviousText();