Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <colinodell@gmail.com>
7
 * (c) 2015 Martin Hasoň <martin.hason@gmail.com>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
 
13
declare(strict_types=1);
14
 
15
namespace League\CommonMark\Extension\Attributes\Parser;
16
 
17
use League\CommonMark\Extension\Attributes\Util\AttributesHelper;
18
use League\CommonMark\Parser\Block\BlockStart;
19
use League\CommonMark\Parser\Block\BlockStartParserInterface;
20
use League\CommonMark\Parser\Cursor;
21
use League\CommonMark\Parser\MarkdownParserStateInterface;
22
 
23
final class AttributesBlockStartParser implements BlockStartParserInterface
24
{
25
    public function tryStart(Cursor $cursor, MarkdownParserStateInterface $parserState): ?BlockStart
26
    {
27
        $originalPosition = $cursor->getPosition();
28
        $attributes       = AttributesHelper::parseAttributes($cursor);
29
 
30
        if ($attributes === [] && $originalPosition === $cursor->getPosition()) {
31
            return BlockStart::none();
32
        }
33
 
34
        if ($cursor->getNextNonSpaceCharacter() !== null) {
35
            return BlockStart::none();
36
        }
37
 
38
        return BlockStart::of(new AttributesBlockContinueParser($attributes, $parserState->getActiveBlockParser()->getBlock()))->at($cursor);
39
    }
40
}