当前位置: 首页>>代码示例>>PHP>>正文


PHP Cursor::isAtEnd方法代码示例

本文整理汇总了PHP中League\CommonMark\Cursor::isAtEnd方法的典型用法代码示例。如果您正苦于以下问题:PHP Cursor::isAtEnd方法的具体用法?PHP Cursor::isAtEnd怎么用?PHP Cursor::isAtEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\CommonMark\Cursor的用法示例。


在下文中一共展示了Cursor::isAtEnd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 /**
  * Attempt to parse a link reference, modifying the refmap.
  *
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(Cursor $cursor)
 {
     if ($cursor->isAtEnd()) {
         return false;
     }
     $initialState = $cursor->saveState();
     $matchChars = LinkParserHelper::parseLinkLabel($cursor);
     if ($matchChars === 0) {
         $cursor->restoreState($initialState);
         return false;
     }
     // We need to trim the opening and closing brackets from the previously-matched text
     $label = substr($cursor->getPreviousText(), 1, -1);
     if (preg_match('/[^\\s]/', $label) === 0) {
         $cursor->restoreState($initialState);
         return false;
     }
     if ($cursor->getCharacter() !== ':') {
         $cursor->restoreState($initialState);
         return false;
     }
     // Advance past the colon
     $cursor->advance();
     // Link URL
     $cursor->advanceToFirstNonSpace();
     $destination = LinkParserHelper::parseLinkDestination($cursor);
     if (empty($destination)) {
         $cursor->restoreState($initialState);
         return false;
     }
     $previousState = $cursor->saveState();
     $cursor->advanceToFirstNonSpace();
     $title = LinkParserHelper::parseLinkTitle($cursor);
     if ($title === null) {
         $title = '';
         $cursor->restoreState($previousState);
     }
     // Make sure we're at line end:
     if ($cursor->match('/^ *(?:\\n|$)/') === null) {
         $cursor->restoreState($initialState);
         return false;
     }
     if (!$this->referenceMap->contains($label)) {
         $reference = new Reference($label, $destination, $title);
         $this->referenceMap->addReference($reference);
     }
     return true;
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:55,代码来源:ReferenceParser.php

示例2: parse

 /**
  * Attempt to parse a link reference, modifying the refmap.
  *
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(Cursor $cursor)
 {
     if ($cursor->isAtEnd()) {
         return false;
     }
     $initialState = $cursor->saveState();
     $matchChars = LinkParserHelper::parseLinkLabel($cursor);
     if ($matchChars === 0) {
         $cursor->restoreState($initialState);
         return false;
     }
     // We need to trim the opening and closing brackets from the previously-matched text
     $label = substr($cursor->getPreviousText(), 1, -1);
     if (preg_match('/[^\\s]/', $label) === 0) {
         $cursor->restoreState($initialState);
         return false;
     }
     if ($cursor->getCharacter() !== ':') {
         $cursor->restoreState($initialState);
         return false;
     }
     // Advance past the colon
     $cursor->advance();
     // Link URL
     $cursor->advanceToFirstNonSpace();
     $destination = LinkParserHelper::parseLinkDestination($cursor);
     if (empty($destination)) {
         $cursor->restoreState($initialState);
         return false;
     }
     $previousState = $cursor->saveState();
     $cursor->advanceToFirstNonSpace();
     $title = LinkParserHelper::parseLinkTitle($cursor);
     if ($title === null) {
         $title = '';
         $cursor->restoreState($previousState);
     }
     // Make sure we're at line end:
     $atLineEnd = true;
     if ($cursor->match('/^ *(?:\\n|$)/') === null) {
         if ($title === '') {
             $atLineEnd = false;
         } else {
             // The potential title we found is not at the line end,
             // but it could still be a legal link reference if we
             // discard the title
             $title = '';
             // rewind before spaces
             $cursor->restoreState($previousState);
             // and instead check if the link URL is at the line end
             $atLineEnd = $cursor->match('/^ *(?:\\n|$)/') !== null;
         }
     }
     if (!$atLineEnd) {
         $cursor->restoreState($initialState);
         return false;
     }
     if (!$this->referenceMap->contains($label)) {
         $reference = new Reference($label, $destination, $title);
         $this->referenceMap->addReference($reference);
     }
     return true;
 }
开发者ID:LyricFinancial,项目名称:integration-guides,代码行数:70,代码来源:ReferenceParser.php


注:本文中的League\CommonMark\Cursor::isAtEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。