From 7446fc7c6e62457bf37fef22e0a0e96956dee089 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 28 Jul 2021 12:12:38 +0200 Subject: [PATCH] [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 --- src/Http/Controllers/Inertia/PrivacyPolicyController.php | 9 ++------- .../Controllers/Inertia/TermsOfServiceController.php | 9 ++------- .../Controllers/Livewire/PrivacyPolicyController.php | 9 ++------- .../Controllers/Livewire/TermsOfServiceController.php | 9 ++------- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/Http/Controllers/Inertia/PrivacyPolicyController.php b/src/Http/Controllers/Inertia/PrivacyPolicyController.php index 722914a2e..d8c459123 100644 --- a/src/Http/Controllers/Inertia/PrivacyPolicyController.php +++ b/src/Http/Controllers/Inertia/PrivacyPolicyController.php @@ -4,11 +4,9 @@ use Illuminate\Http\Request; use Illuminate\Routing\Controller; +use Illuminate\Support\Str; use Inertia\Inertia; use Laravel\Jetstream\Jetstream; -use League\CommonMark\CommonMarkConverter; -use League\CommonMark\Environment; -use League\CommonMark\Extension\GithubFlavoredMarkdownExtension; class PrivacyPolicyController extends Controller { @@ -22,11 +20,8 @@ public function show(Request $request) { $policyFile = Jetstream::localizedMarkdownPath('policy.md'); - $environment = Environment::createCommonMarkEnvironment(); - $environment->addExtension(new GithubFlavoredMarkdownExtension()); - return Inertia::render('PrivacyPolicy', [ - 'policy' => (new CommonMarkConverter([], $environment))->convertToHtml(file_get_contents($policyFile)), + 'policy' => Str::markdown(file_get_contents($policyFile)), ]); } } diff --git a/src/Http/Controllers/Inertia/TermsOfServiceController.php b/src/Http/Controllers/Inertia/TermsOfServiceController.php index 7d8ea918d..778925c80 100644 --- a/src/Http/Controllers/Inertia/TermsOfServiceController.php +++ b/src/Http/Controllers/Inertia/TermsOfServiceController.php @@ -4,11 +4,9 @@ use Illuminate\Http\Request; use Illuminate\Routing\Controller; +use Illuminate\Support\Str; use Inertia\Inertia; use Laravel\Jetstream\Jetstream; -use League\CommonMark\CommonMarkConverter; -use League\CommonMark\Environment; -use League\CommonMark\Extension\GithubFlavoredMarkdownExtension; class TermsOfServiceController extends Controller { @@ -22,11 +20,8 @@ public function show(Request $request) { $termsFile = Jetstream::localizedMarkdownPath('terms.md'); - $environment = Environment::createCommonMarkEnvironment(); - $environment->addExtension(new GithubFlavoredMarkdownExtension()); - return Inertia::render('TermsOfService', [ - 'terms' => (new CommonMarkConverter([], $environment))->convertToHtml(file_get_contents($termsFile)), + 'terms' => Str::markdown(file_get_contents($termsFile)), ]); } } diff --git a/src/Http/Controllers/Livewire/PrivacyPolicyController.php b/src/Http/Controllers/Livewire/PrivacyPolicyController.php index 1789bb676..5dbdb6969 100644 --- a/src/Http/Controllers/Livewire/PrivacyPolicyController.php +++ b/src/Http/Controllers/Livewire/PrivacyPolicyController.php @@ -4,10 +4,8 @@ use Illuminate\Http\Request; use Illuminate\Routing\Controller; +use Illuminate\Support\Str; use Laravel\Jetstream\Jetstream; -use League\CommonMark\CommonMarkConverter; -use League\CommonMark\Environment; -use League\CommonMark\Extension\GithubFlavoredMarkdownExtension; class PrivacyPolicyController extends Controller { @@ -21,11 +19,8 @@ public function show(Request $request) { $policyFile = Jetstream::localizedMarkdownPath('policy.md'); - $environment = Environment::createCommonMarkEnvironment(); - $environment->addExtension(new GithubFlavoredMarkdownExtension()); - return view('policy', [ - 'policy' => (new CommonMarkConverter([], $environment))->convertToHtml(file_get_contents($policyFile)), + 'policy' => Str::markdown(file_get_contents($policyFile)), ]); } } diff --git a/src/Http/Controllers/Livewire/TermsOfServiceController.php b/src/Http/Controllers/Livewire/TermsOfServiceController.php index 185c31732..835d770e6 100644 --- a/src/Http/Controllers/Livewire/TermsOfServiceController.php +++ b/src/Http/Controllers/Livewire/TermsOfServiceController.php @@ -4,10 +4,8 @@ use Illuminate\Http\Request; use Illuminate\Routing\Controller; +use Illuminate\Support\Str; use Laravel\Jetstream\Jetstream; -use League\CommonMark\CommonMarkConverter; -use League\CommonMark\Environment; -use League\CommonMark\Extension\GithubFlavoredMarkdownExtension; class TermsOfServiceController extends Controller { @@ -21,11 +19,8 @@ public function show(Request $request) { $termsFile = Jetstream::localizedMarkdownPath('terms.md'); - $environment = Environment::createCommonMarkEnvironment(); - $environment->addExtension(new GithubFlavoredMarkdownExtension()); - return view('terms', [ - 'terms' => (new CommonMarkConverter([], $environment))->convertToHtml(file_get_contents($termsFile)), + 'terms' => Str::markdown(file_get_contents($termsFile)), ]); } }