1 | <?php |
||
19 | class Converter implements MarkdownConverterInterface |
||
20 | { |
||
21 | /** |
||
22 | * The document parser instance. |
||
23 | * |
||
24 | * @var DocParserInterface |
||
25 | */ |
||
26 | protected $docParser; |
||
27 | |||
28 | /** |
||
29 | * The html renderer instance. |
||
30 | * |
||
31 | * @var ElementRendererInterface |
||
32 | */ |
||
33 | protected $htmlRenderer; |
||
34 | |||
35 | /** |
||
36 | * Create a new commonmark converter instance. |
||
37 | * |
||
38 | * @param DocParserInterface $docParser |
||
39 | * @param ElementRendererInterface $htmlRenderer |
||
40 | */ |
||
41 | 2361 | public function __construct(DocParserInterface $docParser, ElementRendererInterface $htmlRenderer) |
|
42 | { |
||
43 | 2361 | if (!($this instanceof CommonMarkConverter)) { |
|
44 | @trigger_error(sprintf('The %s class is deprecated since league/commonmark 1.4, use %s instead.', self::class, CommonMarkConverter::class), E_USER_DEPRECATED); |
||
45 | } |
||
46 | |||
47 | 2361 | $this->docParser = $docParser; |
|
48 | 2361 | $this->htmlRenderer = $htmlRenderer; |
|
49 | 2361 | } |
|
50 | |||
51 | /** |
||
52 | * Converts CommonMark to HTML. |
||
53 | * |
||
54 | * @param string $commonMark |
||
55 | * |
||
56 | * @throws \RuntimeException |
||
57 | * |
||
58 | * @return string |
||
59 | * |
||
60 | * @api |
||
61 | */ |
||
62 | 2352 | public function convertToHtml(string $commonMark): string |
|
68 | |||
69 | /** |
||
70 | * Converts CommonMark to HTML. |
||
71 | * |
||
72 | * @see Converter::convertToHtml |
||
73 | * |
||
74 | * @param string $commonMark |
||
75 | * |
||
76 | * @throws \RuntimeException |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | 3 | public function __invoke(string $commonMark): string |
|
84 | } |
||
85 |