1<?php
2
3/*
4 * This file is part of the league/commonmark package.
5 *
6 * (c) Colin O'Dell <colinodell@gmail.com>
7 *
8 * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
9 *  - (c) John MacFarlane
10 *
11 * For the full copyright and license information, please view the LICENSE
12 * file that was distributed with this source code.
13 */
14
15namespace League\CommonMark;
16
17/**
18 * Converts CommonMark-compatible Markdown to HTML.
19 */
20class CommonMarkConverter extends MarkdownConverter
21{
22    /**
23     * The currently-installed version.
24     *
25     * This might be a typical `x.y.z` version, or `x.y-dev`.
26     *
27     * @deprecated in 1.5.0 and will be removed from 2.0.0.
28     *   Use \Composer\InstalledVersions provided by composer-runtime-api instead.
29     */
30    public const VERSION = '1.6.7';
31
32    /**
33     * Create a new commonmark converter instance.
34     *
35     * @param array<string, mixed>      $config
36     * @param EnvironmentInterface|null $environment
37     */
38    public function __construct(array $config = [], EnvironmentInterface $environment = null)
39    {
40        if ($environment === null) {
41            $environment = Environment::createCommonMarkEnvironment();
42        } else {
43            @\trigger_error(\sprintf('Passing an $environment into the "%s" constructor is deprecated in 1.6 and will not be supported in 2.0; use MarkdownConverter instead. See https://commonmark.thephpleague.com/2.0/upgrading/consumers/#commonmarkconverter-and-githubflavoredmarkdownconverter-constructors for more details.', self::class), \E_USER_DEPRECATED);
44        }
45
46        if ($environment instanceof ConfigurableEnvironmentInterface) {
47            $environment->mergeConfig($config);
48        }
49
50        parent::__construct($environment);
51    }
52}
53