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


PHP Cursor::match方法代碼示例

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


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

示例1: getElementParts

 /**
  * @param  string $mediaType
  * @return mixed
  */
 protected function getElementParts($mediaType)
 {
     $label = trim($this->cursor->match('/^\\[(?:[^\\\\\\[\\]]|\\\\[\\[\\]]){0,750}\\]/'), '[]');
     $url = trim(LinkParserHelper::parseLinkDestination($this->cursor), '()');
     if ($label === null || $url === null) {
         return $this->cancel();
     }
     return $this->getElement($mediaType, $label, $url);
 }
開發者ID:gibboncms,項目名稱:gibbon,代碼行數:13,代碼來源:MediaParser.php

示例2: parseLinkTitle

 /**
  * Attempt to parse link title (sans quotes)
  *
  * @param Cursor $cursor
  *
  * @return null|string The string, or null if no match
  */
 public static function parseLinkTitle(Cursor $cursor)
 {
     if ($title = $cursor->match(RegexHelper::getInstance()->getLinkTitleRegex())) {
         // Chop off quotes from title and unescape
         return RegexHelper::unescape(substr($title, 1, strlen($title) - 2));
     }
 }
開發者ID:colinodell,項目名稱:commonmark-php,代碼行數:14,代碼來源:LinkParserHelper.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)
 {
     $previousState = $cursor->saveState();
     $indent = $cursor->advanceToFirstNonSpace();
     $fence = $cursor->match('/^`{3,}(?!.*`)|^~{3,}(?!.*~)/');
     if (!$fence) {
         $cursor->restoreState($previousState);
         return false;
     }
     // fenced code block
     $fenceLength = strlen($fence);
     $context->addBlock(new FencedCode($fenceLength, $fence[0], $indent));
     return true;
 }
開發者ID:R3alflash,項目名稱:BFAdminCP,代碼行數:20,代碼來源:FencedCodeParser.php

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

示例6: parse

 /**
  * @param ContextInterface $context
  * @param Cursor $cursor
  *
  * @return bool
  */
 public function parse(ContextInterface $context, Cursor $cursor)
 {
     if ($cursor->isIndented()) {
         return false;
     }
     $previousState = $cursor->saveState();
     $cursor->advanceToFirstNonSpace();
     $fence = $cursor->match('/^\\[TOC\\]/');
     if (is_null($fence)) {
         $cursor->restoreState($previousState);
         return false;
     }
     $context->addBlock(new TableOfContents());
     return true;
 }
開發者ID:rlugojr,項目名稱:daux.io,代碼行數:21,代碼來源:TableOfContentsParser.php

示例7: handleRemainingContents

 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  */
 public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
 {
     $context->getTip()->addLine($cursor->getRemainder());
     // Check for end condition
     if ($this->type >= self::TYPE_1_CODE_CONTAINER && $this->type <= self::TYPE_5_CDATA) {
         if ($cursor->match(RegexHelper::getHtmlBlockCloseRegex($this->type)) !== null) {
             $this->finalize($context, $context->getLineNumber());
         }
     }
 }
開發者ID:colinodell,項目名稱:commonmark-php,代碼行數:14,代碼來源:HtmlBlock.php


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