當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cursor::advance方法代碼示例

本文整理匯總了PHP中League\CommonMark\Cursor::advance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cursor::advance方法的具體用法?PHP Cursor::advance怎麽用?PHP Cursor::advance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在League\CommonMark\Cursor的用法示例。


在下文中一共展示了Cursor::advance方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parse

 /**
  * @param  \League\CommonMark\ContextInterface $context
  * @param  \League\CommonMark\InlineParserContext $inlineContext
  * @return bool
  */
 public function parse(ContextInterface $context, InlineParserContext $inlineContext)
 {
     $this->context = $context;
     $this->inlineContext = $inlineContext;
     $this->cursor = $inlineContext->getCursor();
     $this->originalState = $this->cursor->saveState();
     $this->cursor->advance();
     return $this->parseMediaType();
 }
開發者ID:gibboncms,項目名稱:gibbon,代碼行數:14,代碼來源:MediaParser.php

示例2: matchesNextLine

 public function matchesNextLine(Cursor $cursor)
 {
     if ($cursor->getIndent() <= 3 && $cursor->getFirstNonSpaceCharacter() === '>') {
         $cursor->advanceToFirstNonSpace();
         $cursor->advance();
         if ($cursor->getCharacter() === ' ') {
             $cursor->advance();
         }
         return true;
     }
     return false;
 }
開發者ID:alvarobfdev,項目名稱:LaravelCore,代碼行數:12,代碼來源:BlockQuote.php

示例3: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->getFirstNonSpaceCharacter() !== '>') {
         return false;
     }
     $cursor->advanceToFirstNonSpace();
     $cursor->advance();
     if ($cursor->getCharacter() === ' ') {
         $cursor->advance();
     }
     $context->addBlock(new BlockQuote());
     return true;
 }
開發者ID:alvarobfdev,項目名稱:LaravelCore,代碼行數:19,代碼來源:BlockQuoteParser.php

示例4: parse

 public function parse(ContextInterface $context, Cursor $cursor)
 {
     $inlineParserContext = new InlineParserContext($cursor);
     while (($character = $cursor->getCharacter()) !== null) {
         if ($matchingParsers = $this->environment->getInlineParsersForCharacter($character)) {
             foreach ($matchingParsers as $parser) {
                 if ($parser->parse($context, $inlineParserContext)) {
                     continue 2;
                 }
             }
         }
         // We reach here if none of the parsers can handle the input
         // Attempt to match multiple non-special characters at once
         $text = $cursor->match($this->environment->getInlineParserCharacterRegex());
         // This might fail if we're currently at a special character which wasn't parsed; if so, just add that character
         if ($text === null) {
             $cursor->advance();
             $text = $character;
         }
         $lastInline = $inlineParserContext->getInlines()->last();
         if ($lastInline instanceof Text && !isset($lastInline->data['delim'])) {
             $lastInline->append($text);
         } else {
             $inlineParserContext->getInlines()->add(new Text($text));
         }
     }
     foreach ($this->environment->getInlineProcessors() as $inlineProcessor) {
         $inlineProcessor->processInlines($inlineParserContext->getInlines(), $inlineParserContext->getDelimiterStack());
     }
     return $inlineParserContext->getInlines();
 }
開發者ID:R3alflash,項目名稱:BFAdminCP,代碼行數:31,代碼來源:InlineParserEngine.php

示例5: matchesNextLine

 public function matchesNextLine(Cursor $cursor)
 {
     if (!$cursor->isIndented() && $cursor->getFirstNonSpaceCharacter() === '>') {
         $cursor->advanceToFirstNonSpace();
         $cursor->advance();
         $cursor->advanceBySpaceOrTab();
         return true;
     }
     return false;
 }
開發者ID:colinodell,項目名稱:commonmark-php,代碼行數:10,代碼來源:BlockQuote.php

示例6: matchesNextLine

 public function matchesNextLine(Cursor $cursor)
 {
     if ($cursor->getIndent() <= 3 && in_array($cursor->getFirstNonSpaceCharacter(), static::getIconBlockTypes())) {
         $cursor->advanceToFirstNonSpace();
         if ($cursor->peek() === '>') {
             $cursor->advanceBy(2);
             if ($cursor->getCharacter() === ' ') {
                 $cursor->advance();
             }
             return true;
         }
     }
     return false;
 }
開發者ID:austinvernsonger,項目名稱:markua,代碼行數:14,代碼來源:IconBlock.php

示例7: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->getFirstNonSpaceCharacter() !== 'A' || $cursor->getCharacter($cursor->getFirstNonSpacePosition() + 1) !== '>') {
         return false;
     }
     $cursor->advanceToFirstNonSpace();
     if ($cursor->peek() === '>') {
         $cursor->advanceBy(2);
         if ($cursor->getCharacter() === ' ') {
             $cursor->advance();
         }
     }
     $context->addBlock(new Aside());
     return true;
 }
開發者ID:austinvernsonger,項目名稱:markua,代碼行數:21,代碼來源:AsideParser.php

示例8: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if (!in_array($cursor->getFirstNonSpaceCharacter(), IconBlock::getIconBlockTypes()) || $cursor->getCharacter($cursor->getFirstNonSpacePosition() + 1) !== '>') {
         return false;
     }
     $type = $cursor->getFirstNonSpaceCharacter();
     $cursor->advanceToFirstNonSpace();
     if ($cursor->peek() === '>') {
         $cursor->advanceBy(2);
         if ($cursor->getCharacter() === ' ') {
             $cursor->advance();
         }
     }
     $context->addBlock(new IconBlock($type));
     return true;
 }
開發者ID:austinvernsonger,項目名稱:markua,代碼行數:22,代碼來源:IconBlockParser.php

示例9: tryParseInlineLinkAndTitle

 /**
  * @param Cursor $cursor
  *
  * @return array|bool
  */
 protected function tryParseInlineLinkAndTitle(Cursor $cursor)
 {
     $cursor->advance();
     $cursor->advanceToFirstNonSpace();
     if (($dest = LinkParserHelper::parseLinkDestination($cursor)) === null) {
         return false;
     }
     $cursor->advanceToFirstNonSpace();
     $title = null;
     // make sure there's a space before the title:
     if (preg_match('/^\\s/', $cursor->peek(-1))) {
         $title = LinkParserHelper::parseLinkTitle($cursor) ?: '';
     }
     $cursor->advanceToFirstNonSpace();
     if (!$cursor->match('/^\\)/')) {
         return false;
     }
     return ['url' => $dest, 'title' => $title];
 }
開發者ID:alvarobfdev,項目名稱:applog,代碼行數:24,代碼來源:CloseBracketParser.php

示例10: tryParseInlineLinkAndTitle

 /**
  * @param Cursor $cursor
  *
  * @return array|bool
  */
 protected function tryParseInlineLinkAndTitle(Cursor $cursor)
 {
     if ($cursor->getCharacter() !== '(') {
         return false;
     }
     $previousState = $cursor->saveState();
     $cursor->advance();
     $cursor->advanceToFirstNonSpace();
     if (($dest = LinkParserHelper::parseLinkDestination($cursor)) === null) {
         $cursor->restoreState($previousState);
         return false;
     }
     $cursor->advanceToFirstNonSpace();
     $title = null;
     // make sure there's a space before the title:
     if (preg_match(RegexHelper::REGEX_WHITESPACE_CHAR, $cursor->peek(-1))) {
         $title = LinkParserHelper::parseLinkTitle($cursor) ?: '';
     }
     $cursor->advanceToFirstNonSpace();
     if ($cursor->match('/^\\)/') === null) {
         $cursor->restoreState($previousState);
         return false;
     }
     return ['url' => $dest, 'title' => $title];
 }
開發者ID:colinodell,項目名稱:commonmark-php,代碼行數:30,代碼來源:CloseBracketParser.php


注:本文中的League\CommonMark\Cursor::advance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。