Skip to content

Commit

Permalink
[9.x] Drop CommonMark v1 support (#37953)
Browse files Browse the repository at this point in the history
* Update to CommonMark v2

* Update composer.json files
  • Loading branch information
driesvints authored Jul 10, 2021
1 parent 4186af1 commit 32a0e8e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"doctrine/inflector": "^2.0",
"dragonmantank/cron-expression": "^3.1",
"egulias/email-validator": "^3.1",
"league/commonmark": "^1.3|^2.0",
"league/commonmark": "^2.0",
"league/flysystem": "^2.0",
"monolog/monolog": "^2.0",
"nesbot/carbon": "^2.31",
Expand Down
11 changes: 8 additions & 3 deletions src/Illuminate/Mail/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
use Illuminate\Contracts\View\Factory as ViewFactory;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\Table\TableExtension;
use League\CommonMark\MarkdownConverter;
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;

class Markdown
Expand Down Expand Up @@ -103,11 +105,14 @@ public function renderText($view, array $data = [])
*/
public static function parse($text)
{
$converter = new CommonMarkConverter([
$environment = new Environment([
'allow_unsafe_links' => false,
]);

$converter->getEnvironment()->addExtension(new TableExtension());
$environment->addExtension(new CommonMarkCoreExtension);
$environment->addExtension(new TableExtension);

$converter = new MarkdownConverter($environment);

return new HtmlString((string) $converter->convertToHtml($text));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Mail/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"illuminate/contracts": "^9.0",
"illuminate/macroable": "^9.0",
"illuminate/support": "^9.0",
"league/commonmark": "^1.3|^2.0",
"league/commonmark": "^2.0",
"psr/log": "^1.0",
"swiftmailer/swiftmailer": "^6.2.7",
"tijsverkoyen/css-to-inline-styles": "^2.2.2"
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"suggest": {
"illuminate/filesystem": "Required to use the composer class (^9.0).",
"league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^1.3|^2.0).",
"league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.0).",
"ramsey/uuid": "Required to use Str::uuid() (^4.0).",
"symfony/process": "Required to use the composer class (^5.3).",
"symfony/var-dumper": "Required to use the dd function (^5.3).",
Expand Down

0 comments on commit 32a0e8e

Please sign in to comment.