/**
  * @param \ViKon\Parser\Token     $token
  * @param \ViKon\Parser\TokenList $tokenList
  *
  * @return string
  * @throws \ViKon\Parser\LexerException
  */
 public function renderReference(Token $token, TokenList $tokenList)
 {
     $reference = $token->get('reference');
     $label = $token->get('label');
     if ($reference instanceof Token) {
         $referenceToken = $reference;
     } else {
         if (empty($reference) === '') {
             $reference = strtolower($token->get('label'));
         }
         $tokens = $tokenList->getTokensByCallback(function (Token $token) use($reference) {
             return $token->getName() === ReferenceRule::NAME && $token->get('reference', null) === $reference;
         });
         // Get first token (if not found return full match)
         if (($referenceToken = reset($tokens)) === false) {
             return $token->get('match', '');
         }
         $referenceToken->set('used', true);
     }
     $url = $referenceToken->get('url');
     $title = $referenceToken->get('title', '');
     if (empty($title)) {
         return "<a href=\"{$url}\">{$label}</a>";
     }
     return "<a href=\"{$url}\" title=\"{$title}\">{$label}</a>";
 }
 /**
  * @param \ViKon\Parser\Token     $token
  * @param \ViKon\Parser\TokenList $tokenList
  *
  * @return string
  * @throws \ViKon\Parser\LexerException
  */
 public function renderReference(Token $token, TokenList $tokenList)
 {
     $reference = $token->get('reference');
     $alt = $token->get('alt');
     if ($reference instanceof Token) {
         $referenceToken = $reference;
     } else {
         $tokens = $tokenList->getTokensByCallback(function (Token $token) use($reference) {
             return $token->getName() === ReferenceRule::NAME && $token->get('reference', null) === $reference;
         });
         // Get first token (if not found return full match)
         if (($referenceToken = reset($tokens)) === false) {
             return $token->get('match', '');
         }
         $referenceToken->set('used', true);
     }
     $url = $referenceToken->get('url');
     $title = $referenceToken->get('title', '');
     if (empty($title)) {
         return "<img alt=\"{$alt}\" src=\"{$url}\"/>";
     }
     return "<img alt=\"{$alt}\" src=\"{$url}\" title=\"{$title}\" />";
 }