Skip to content

Commit 7446fc7

Browse files
driesvintsmikeroq
andauthored
[2.x] Support both CommonMark v1 & v2 (#845)
* Fix commonmark 2.0 changes breaking TOS/PP * Fix composer.json * Use Str::markdown Co-authored-by: Mike Roquemore <[email protected]>
1 parent b33a95d commit 7446fc7

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

src/Http/Controllers/Inertia/PrivacyPolicyController.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
use Illuminate\Http\Request;
66
use Illuminate\Routing\Controller;
7+
use Illuminate\Support\Str;
78
use Inertia\Inertia;
89
use Laravel\Jetstream\Jetstream;
9-
use League\CommonMark\CommonMarkConverter;
10-
use League\CommonMark\Environment;
11-
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
1210

1311
class PrivacyPolicyController extends Controller
1412
{
@@ -22,11 +20,8 @@ public function show(Request $request)
2220
{
2321
$policyFile = Jetstream::localizedMarkdownPath('policy.md');
2422

25-
$environment = Environment::createCommonMarkEnvironment();
26-
$environment->addExtension(new GithubFlavoredMarkdownExtension());
27-
2823
return Inertia::render('PrivacyPolicy', [
29-
'policy' => (new CommonMarkConverter([], $environment))->convertToHtml(file_get_contents($policyFile)),
24+
'policy' => Str::markdown(file_get_contents($policyFile)),
3025
]);
3126
}
3227
}

src/Http/Controllers/Inertia/TermsOfServiceController.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
use Illuminate\Http\Request;
66
use Illuminate\Routing\Controller;
7+
use Illuminate\Support\Str;
78
use Inertia\Inertia;
89
use Laravel\Jetstream\Jetstream;
9-
use League\CommonMark\CommonMarkConverter;
10-
use League\CommonMark\Environment;
11-
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
1210

1311
class TermsOfServiceController extends Controller
1412
{
@@ -22,11 +20,8 @@ public function show(Request $request)
2220
{
2321
$termsFile = Jetstream::localizedMarkdownPath('terms.md');
2422

25-
$environment = Environment::createCommonMarkEnvironment();
26-
$environment->addExtension(new GithubFlavoredMarkdownExtension());
27-
2823
return Inertia::render('TermsOfService', [
29-
'terms' => (new CommonMarkConverter([], $environment))->convertToHtml(file_get_contents($termsFile)),
24+
'terms' => Str::markdown(file_get_contents($termsFile)),
3025
]);
3126
}
3227
}

src/Http/Controllers/Livewire/PrivacyPolicyController.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
use Illuminate\Http\Request;
66
use Illuminate\Routing\Controller;
7+
use Illuminate\Support\Str;
78
use Laravel\Jetstream\Jetstream;
8-
use League\CommonMark\CommonMarkConverter;
9-
use League\CommonMark\Environment;
10-
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
119

1210
class PrivacyPolicyController extends Controller
1311
{
@@ -21,11 +19,8 @@ public function show(Request $request)
2119
{
2220
$policyFile = Jetstream::localizedMarkdownPath('policy.md');
2321

24-
$environment = Environment::createCommonMarkEnvironment();
25-
$environment->addExtension(new GithubFlavoredMarkdownExtension());
26-
2722
return view('policy', [
28-
'policy' => (new CommonMarkConverter([], $environment))->convertToHtml(file_get_contents($policyFile)),
23+
'policy' => Str::markdown(file_get_contents($policyFile)),
2924
]);
3025
}
3126
}

src/Http/Controllers/Livewire/TermsOfServiceController.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
use Illuminate\Http\Request;
66
use Illuminate\Routing\Controller;
7+
use Illuminate\Support\Str;
78
use Laravel\Jetstream\Jetstream;
8-
use League\CommonMark\CommonMarkConverter;
9-
use League\CommonMark\Environment;
10-
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
119

1210
class TermsOfServiceController extends Controller
1311
{
@@ -21,11 +19,8 @@ public function show(Request $request)
2119
{
2220
$termsFile = Jetstream::localizedMarkdownPath('terms.md');
2321

24-
$environment = Environment::createCommonMarkEnvironment();
25-
$environment->addExtension(new GithubFlavoredMarkdownExtension());
26-
2722
return view('terms', [
28-
'terms' => (new CommonMarkConverter([], $environment))->convertToHtml(file_get_contents($termsFile)),
23+
'terms' => Str::markdown(file_get_contents($termsFile)),
2924
]);
3025
}
3126
}

0 commit comments

Comments
 (0)