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


PHP Cursor::getCharacter方法代码示例

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


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

示例1: parse

 public static function parse(Cursor $cursor)
 {
     if (null === self::$regexp) {
         $regex = RegexHelper::getInstance();
         self::$regexp = sprintf('/^\\s*([.#][_a-z0-9-]+|%s%s)(?<!})\\s*/i', $regex->getPartialRegex(RegexHelper::ATTRIBUTENAME), $regex->getPartialRegex(RegexHelper::ATTRIBUTEVALUESPEC));
     }
     $state = $cursor->saveState();
     $cursor->advanceToFirstNonSpace();
     if ('{' !== $cursor->getCharacter()) {
         $cursor->restoreState($state);
         return [];
     }
     $cursor->advanceBy(1);
     if (':' === $cursor->getCharacter()) {
         $cursor->advanceBy(1);
     }
     $attributes = [];
     while ($attribute = trim($cursor->match(self::$regexp))) {
         if ('#' === $attribute[0]) {
             $attributes['id'] = substr($attribute, 1);
             continue;
         }
         if ('.' === $attribute[0]) {
             $attributes['class'][] = substr($attribute, 1);
             continue;
         }
         list($name, $value) = explode('=', $attribute, 2);
         $first = $value[0];
         $last = substr($value, -1);
         if (('"' === $first && '"' === $last || "'" === $first && "'" === $last) && strlen($value) > 1) {
             $value = substr($value, 1, -1);
         }
         if ('class' === strtolower(trim($name))) {
             foreach (array_filter(explode(' ', trim($value))) as $class) {
                 $attributes['class'][] = $class;
             }
         } else {
             $attributes[trim($name)] = trim($value);
         }
     }
     if (0 === $cursor->advanceWhileMatches('}')) {
         $cursor->restoreState($state);
         return [];
     }
     if (isset($attributes['class'])) {
         $attributes['class'] = implode(' ', $attributes['class']);
     }
     return $attributes;
 }
开发者ID:unicorn-fail,项目名称:commonmark.unicorn.fail,代码行数:49,代码来源:AttributesUtils.php

示例2: 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

示例3: 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

示例4: 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

示例5: parseReferences

 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  *
  * @return bool
  */
 protected function parseReferences(ContextInterface $context, Cursor $cursor)
 {
     $referenceFound = false;
     while ($cursor->getCharacter() === '[' && $context->getReferenceParser()->parse($cursor)) {
         $this->finalStringContents = $cursor->getRemainder();
         $referenceFound = true;
     }
     return $referenceFound;
 }
开发者ID:LyricFinancial,项目名称:integration-guides,代码行数:15,代码来源:Paragraph.php

示例6: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return ArrayCollection
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     $inlineParserContext = new InlineParserContext($cursor);
     while (($character = $cursor->getCharacter()) !== null) {
         if (!$this->parseCharacter($character, $context, $inlineParserContext)) {
             $this->addPlainText($character, $inlineParserContext);
         }
     }
     $this->processInlines($inlineParserContext);
     return $inlineParserContext->getInlines();
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:17,代码来源:InlineParserEngine.php

示例7: 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

示例8: 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

示例9: 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

示例10: calculateListMarkerPadding

 /**
  * @param Cursor $cursor
  * @param int    $markerLength
  *
  * @return int
  */
 private function calculateListMarkerPadding(Cursor $cursor, $markerLength)
 {
     $start = $cursor->saveState();
     $spacesStartCol = $cursor->getColumn();
     do {
         $cursor->advanceBy(1, true);
         $nextChar = $cursor->getCharacter();
     } while ($cursor->getColumn() - $spacesStartCol < 5 && ($nextChar === ' ' || $nextChar === "\t"));
     $blankItem = $cursor->peek() === null;
     $spacesAfterMarker = $cursor->getColumn() - $spacesStartCol;
     if ($spacesAfterMarker >= 5 || $spacesAfterMarker < 1 || $blankItem) {
         $cursor->restoreState($start);
         if ($cursor->peek() === ' ') {
             $cursor->advanceBy(1, true);
         }
         return $markerLength + 1;
     }
     return $markerLength + $spacesAfterMarker;
 }
开发者ID:fxcebx,项目名称:commonmark,代码行数:25,代码来源:ListParser.php

示例11: tryParseLink

 /**
  * @param Cursor $cursor
  * @param ReferenceMap $referenceMap
  * @param Delimiter $opener
  * @param int $startPos
  *
  * @return array|bool
  */
 protected function tryParseLink(Cursor $cursor, ReferenceMap $referenceMap, Delimiter $opener, $startPos)
 {
     // Check to see if we have a link/image
     // Inline link?
     if ($cursor->getCharacter() == '(') {
         if ($result = $this->tryParseInlineLinkAndTitle($cursor)) {
             return $result;
         }
     } elseif ($link = $this->tryParseReference($cursor, $referenceMap, $opener, $startPos)) {
         return ['url' => $link->getDestination(), 'title' => $link->getTitle()];
     }
     return false;
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:21,代码来源:CloseBracketParser.php

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