| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
/*
|
|
|
6 |
* This file is part of the league/commonmark package.
|
|
|
7 |
*
|
|
|
8 |
* (c) Colin O'Dell <colinodell@gmail.com>
|
|
|
9 |
*
|
|
|
10 |
* For the full copyright and license information, please view the LICENSE
|
|
|
11 |
* file that was distributed with this source code.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
namespace League\CommonMark\Environment;
|
|
|
15 |
|
|
|
16 |
use League\CommonMark\Delimiter\Processor\DelimiterProcessorInterface;
|
| 991 |
lars |
17 |
use League\CommonMark\Exception\AlreadyInitializedException;
|
| 148 |
lars |
18 |
use League\CommonMark\Extension\ExtensionInterface;
|
|
|
19 |
use League\CommonMark\Node\Node;
|
|
|
20 |
use League\CommonMark\Parser\Block\BlockStartParserInterface;
|
|
|
21 |
use League\CommonMark\Parser\Inline\InlineParserInterface;
|
|
|
22 |
use League\CommonMark\Renderer\NodeRendererInterface;
|
|
|
23 |
use League\Config\ConfigurationProviderInterface;
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Interface for building the Environment with any extensions, parsers, listeners, etc. that it may need
|
|
|
27 |
*/
|
|
|
28 |
interface EnvironmentBuilderInterface extends ConfigurationProviderInterface
|
|
|
29 |
{
|
|
|
30 |
/**
|
|
|
31 |
* Registers the given extension with the Environment
|
| 991 |
lars |
32 |
*
|
|
|
33 |
* @throws AlreadyInitializedException if the Environment has already been initialized
|
| 148 |
lars |
34 |
*/
|
|
|
35 |
public function addExtension(ExtensionInterface $extension): EnvironmentBuilderInterface;
|
|
|
36 |
|
|
|
37 |
/**
|
|
|
38 |
* Registers the given block start parser with the Environment
|
|
|
39 |
*
|
|
|
40 |
* @param BlockStartParserInterface $parser Block parser instance
|
|
|
41 |
* @param int $priority Priority (a higher number will be executed earlier)
|
|
|
42 |
*
|
|
|
43 |
* @return $this
|
| 991 |
lars |
44 |
*
|
|
|
45 |
* @throws AlreadyInitializedException if the Environment has already been initialized
|
| 148 |
lars |
46 |
*/
|
|
|
47 |
public function addBlockStartParser(BlockStartParserInterface $parser, int $priority = 0): EnvironmentBuilderInterface;
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* Registers the given inline parser with the Environment
|
|
|
51 |
*
|
|
|
52 |
* @param InlineParserInterface $parser Inline parser instance
|
|
|
53 |
* @param int $priority Priority (a higher number will be executed earlier)
|
|
|
54 |
*
|
|
|
55 |
* @return $this
|
| 991 |
lars |
56 |
*
|
|
|
57 |
* @throws AlreadyInitializedException if the Environment has already been initialized
|
| 148 |
lars |
58 |
*/
|
|
|
59 |
public function addInlineParser(InlineParserInterface $parser, int $priority = 0): EnvironmentBuilderInterface;
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Registers the given delimiter processor with the Environment
|
|
|
63 |
*
|
|
|
64 |
* @param DelimiterProcessorInterface $processor Delimiter processors instance
|
| 991 |
lars |
65 |
*
|
|
|
66 |
* @throws AlreadyInitializedException if the Environment has already been initialized
|
| 148 |
lars |
67 |
*/
|
|
|
68 |
public function addDelimiterProcessor(DelimiterProcessorInterface $processor): EnvironmentBuilderInterface;
|
|
|
69 |
|
|
|
70 |
/**
|
|
|
71 |
* Registers the given node renderer with the Environment
|
|
|
72 |
*
|
|
|
73 |
* @param string $nodeClass The fully-qualified node element class name the renderer below should handle
|
|
|
74 |
* @param NodeRendererInterface $renderer The renderer responsible for rendering the type of element given above
|
|
|
75 |
* @param int $priority Priority (a higher number will be executed earlier)
|
|
|
76 |
*
|
|
|
77 |
* @psalm-param class-string<Node> $nodeClass
|
|
|
78 |
*
|
|
|
79 |
* @return $this
|
| 991 |
lars |
80 |
*
|
|
|
81 |
* @throws AlreadyInitializedException if the Environment has already been initialized
|
| 148 |
lars |
82 |
*/
|
|
|
83 |
public function addRenderer(string $nodeClass, NodeRendererInterface $renderer, int $priority = 0): EnvironmentBuilderInterface;
|
|
|
84 |
|
|
|
85 |
/**
|
|
|
86 |
* Registers the given event listener
|
|
|
87 |
*
|
|
|
88 |
* @param class-string $eventClass Fully-qualified class name of the event this listener should respond to
|
|
|
89 |
* @param callable $listener Listener to be executed
|
|
|
90 |
* @param int $priority Priority (a higher number will be executed earlier)
|
|
|
91 |
*
|
|
|
92 |
* @return $this
|
| 991 |
lars |
93 |
*
|
|
|
94 |
* @throws AlreadyInitializedException if the Environment has already been initialized
|
| 148 |
lars |
95 |
*/
|
|
|
96 |
public function addEventListener(string $eventClass, callable $listener, int $priority = 0): EnvironmentBuilderInterface;
|
|
|
97 |
}
|