getReference() public method

public getReference ( string $label ) : Reference | null
$label string
return Reference | null
Exemplo n.º 1
0
 /**
  * @param Cursor $cursor
  * @param ReferenceMap $referenceMap
  * @param Delimiter $opener
  * @param int $startPos
  *
  * @return Reference|null
  */
 protected function tryParseReference(Cursor $cursor, ReferenceMap $referenceMap, Delimiter $opener, $startPos)
 {
     $savePos = $cursor->saveState();
     $cursor->advanceToFirstNonSpace();
     $beforeLabel = $cursor->getPosition();
     $n = LinkParserHelper::parseLinkLabel($cursor);
     if ($n === 0 || $n === 2) {
         // Empty or missing second label
         $reflabel = mb_substr($cursor->getLine(), $opener->getIndex(), $startPos - $opener->getIndex(), 'utf-8');
     } else {
         $reflabel = mb_substr($cursor->getLine(), $beforeLabel + 1, $n - 2, 'utf-8');
     }
     if ($n === 0) {
         // If shortcut reference link, rewind before spaces we skipped
         $cursor->restoreState($savePos);
     }
     return $referenceMap->getReference($reflabel);
 }