本文整理匯總了PHP中League\CommonMark\Cursor::getFirstNonSpaceCharacter方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cursor::getFirstNonSpaceCharacter方法的具體用法?PHP Cursor::getFirstNonSpaceCharacter怎麽用?PHP Cursor::getFirstNonSpaceCharacter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類League\CommonMark\Cursor
的用法示例。
在下文中一共展示了Cursor::getFirstNonSpaceCharacter方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
示例2: matchesNextLine
public function matchesNextLine(Cursor $cursor)
{
if (!$cursor->isIndented() && $cursor->getFirstNonSpaceCharacter() === '>') {
$cursor->advanceToFirstNonSpace();
$cursor->advance();
$cursor->advanceBySpaceOrTab();
return true;
}
return false;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: parse
/**
* @param ContextInterface $context
* @param Cursor $cursor
*
* @return bool
*/
public function parse(ContextInterface $context, Cursor $cursor)
{
if ($cursor->isIndented()) {
return false;
}
if ($cursor->getFirstNonSpaceCharacter() !== '<') {
return false;
}
$savedState = $cursor->saveState();
$cursor->advanceToFirstNonSpace();
$line = $cursor->getRemainder();
for ($blockType = 1; $blockType <= 7; $blockType++) {
$match = RegexHelper::matchAt(RegexHelper::getHtmlBlockOpenRegex($blockType), $line);
if ($match !== null && ($blockType < 7 || !$context->getContainer() instanceof Paragraph)) {
$cursor->restoreState($savedState);
$context->addBlock(new HtmlBlock($blockType));
$context->setBlocksParsed(true);
return true;
}
}
$cursor->restoreState($savedState);
return false;
}
示例8: handleRemainingContents
/**
* @param ContextInterface $context
* @param Cursor $cursor
*/
public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
{
/** @var FencedCode $container */
$container = $context->getContainer();
// check for closing code fence
if ($cursor->getIndent() <= 3 && $cursor->getFirstNonSpaceCharacter() == $container->getChar()) {
$match = RegexHelper::matchAll('/^(?:`{3,}|~{3,})(?= *$)/', $cursor->getLine(), $cursor->getFirstNonSpacePosition());
if (strlen($match[0]) >= $container->getLength()) {
// don't add closing fence to container; instead, close it:
$this->setLength(-1);
// -1 means we've passed closer
return;
}
}
$context->getTip()->addLine($cursor->getRemainder());
}