[8.x] Add support for both CommonMark 1.x and 2.x #37954
Conversation
@@ -22,7 +22,7 @@ | |||
"doctrine/inflector": "^1.4|^2.0", | |||
"dragonmantank/cron-expression": "^3.0.2", | |||
"egulias/email-validator": "^2.1.10", | |||
"league/commonmark": "^1.3", | |||
"league/commonmark": "^1.3|^2.0", |
colinodell
Jul 8, 2021
Author
Contributor
Technically you'll want ^2.0beta3
, as the type hints in the first two betas do not support $converter->getEnvironment()->addExtension()
as used below.
Technically you'll want ^2.0beta3
, as the type hints in the first two betas do not support $converter->getEnvironment()->addExtension()
as used below.
], $environment); | ||
]); | ||
|
||
$converter->getEnvironment()->addExtension(new TableExtension()); |
colinodell
Jul 8, 2021
Author
Contributor
To help promote compatibility between the two major versions, 2.0.0-beta3
exposes an Environment
here that can be used to add new extensions. This is not the preferred way to add extensions, and it may be deprecated at some point, but it at least allows for easy compatibility by avoiding the Environment
namespace changes.
To help promote compatibility between the two major versions, 2.0.0-beta3
exposes an Environment
here that can be used to add new extensions. This is not the preferred way to add extensions, and it may be deprecated at some point, but it at least allows for easy compatibility by avoiding the Environment
namespace changes.
|
||
return new HtmlString($converter->convertToHtml($text)); | ||
return new HtmlString((string) $converter->convertToHtml($text)); |
colinodell
Jul 8, 2021
Author
Contributor
In 1.x
the convertToHtml()
method returns a string
. In 2.x
it returns a Stringable
object. Casting the output to a string allows us to support both.
In 1.x
the convertToHtml()
method returns a string
. In 2.x
it returns a Stringable
object. Casting the output to a string allows us to support both.
This PR complements #37953 by allowing users of 8.x to install either major version of the CommonMark library.