本文整理汇总了PHP中League\CommonMark\Cursor::peek方法的典型用法代码示例。如果您正苦于以下问题:PHP Cursor::peek方法的具体用法?PHP Cursor::peek怎么用?PHP Cursor::peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\CommonMark\Cursor
的用法示例。
在下文中一共展示了Cursor::peek方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: matchesNextLine
public function matchesNextLine(Cursor $cursor)
{
if ($cursor->getIndent() <= 3 && $cursor->getFirstNonSpaceCharacter() == 'A') {
$cursor->advanceToFirstNonSpace();
if ($cursor->peek() === '>') {
$cursor->advanceBy(2);
if ($cursor->getCharacter() === ' ') {
$cursor->advance();
}
return true;
}
}
return false;
}
示例2: 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;
}
示例3: 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;
}
示例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;
}
示例5: calculateListMarkerPadding
/**
* @param Cursor $cursor
* @param int $markerLength
*
* @return int
*/
private function calculateListMarkerPadding(Cursor $cursor, $markerLength)
{
$start = $cursor->saveState();
$spacesStartCol = $cursor->getColumn();
while ($cursor->getColumn() - $spacesStartCol < 5) {
if (!$cursor->advanceBySpaceOrTab()) {
break;
}
}
$blankItem = $cursor->peek() === null;
$spacesAfterMarker = $cursor->getColumn() - $spacesStartCol;
if ($spacesAfterMarker >= 5 || $spacesAfterMarker < 1 || $blankItem) {
$cursor->restoreState($start);
$cursor->advanceBySpaceOrTab();
return $markerLength + 1;
}
return $markerLength + $spacesAfterMarker;
}
示例6: calculateListMarkerPadding
/**
* @param Cursor $cursor
* @param int $markerLength
*
* @return int
*/
private function calculateListMarkerPadding(Cursor $cursor, $markerLength)
{
$start = $cursor->saveState();
$spacesStartCol = $cursor->getColumn();
$spacesStartOffset = $cursor->getPosition();
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;
} else {
return $markerLength + $spacesAfterMarker;
}
}