diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 2c37ec7a021..3871aafcb54 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -57,6 +57,7 @@ This serves two purposes: - Reorganized and cleaned up the navigation and sidebar documentation for improved clarity. - Moved the sidebar documentation to the documentation pages section for better organization. - The build command now groups together all `InMemoryPage` instances under one progress bar group in https://github.com/hydephp/develop/pull/1897 +- The `Markdown::render()` method will now always render Markdown using the custom HydePHP Markdown service (thus getting smart features like our Markdown processors) in https://github.com/hydephp/develop/pull/1900 ### Deprecated - for soon-to-be removed features. diff --git a/packages/framework/src/Markdown/MarkdownConverter.php b/packages/framework/src/Markdown/MarkdownConverter.php index ef6265f1a5b..26cb8902afc 100644 --- a/packages/framework/src/Markdown/MarkdownConverter.php +++ b/packages/framework/src/Markdown/MarkdownConverter.php @@ -9,8 +9,6 @@ /** * The base Markdown converter class. - * - * "Extends" \League\CommonMark\CommonMarkConverter. */ class MarkdownConverter extends \League\CommonMark\MarkdownConverter { diff --git a/packages/framework/src/Markdown/Models/Markdown.php b/packages/framework/src/Markdown/Models/Markdown.php index 568ae22be2e..e9c6c80c6a7 100644 --- a/packages/framework/src/Markdown/Models/Markdown.php +++ b/packages/framework/src/Markdown/Models/Markdown.php @@ -5,7 +5,6 @@ namespace Hyde\Markdown\Models; use Hyde\Framework\Services\MarkdownService; -use Hyde\Markdown\MarkdownConverter; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Support\HtmlString; @@ -84,20 +83,13 @@ public static function fromFile(string $path): static /** * Render a Markdown string into HTML. * - * If a source model is provided, the Markdown will be converted using the dynamic MarkdownService, - * otherwise, the pre-configured singleton from the service container will be used instead. + * If a source page class is provided, that class will be used to configure + * the Hyde Markdown converter to enable features specific to that page. * * @return string $html */ public static function render(string $markdown, ?string $pageClass = null): string { - if ($pageClass !== null) { - return (new MarkdownService($markdown, $pageClass))->parse(); - } else { - /** @var MarkdownConverter $converter */ - $converter = app(MarkdownConverter::class); - - return (string) $converter->convert($markdown); - } + return (new MarkdownService($markdown, $pageClass))->parse(); } } diff --git a/packages/framework/tests/Feature/ColoredBlockquoteShortcodesTest.php b/packages/framework/tests/Feature/ColoredBlockquoteShortcodesTest.php index dce752c8313..f12ffed3492 100644 --- a/packages/framework/tests/Feature/ColoredBlockquoteShortcodesTest.php +++ b/packages/framework/tests/Feature/ColoredBlockquoteShortcodesTest.php @@ -12,6 +12,9 @@ */ class ColoredBlockquoteShortcodesTest extends UnitTestCase { + protected static bool $needsKernel = true; + protected static bool $needsConfig = true; + public function testSignature() { $this->assertSame('>', ColoredBlockquotes::signature()); diff --git a/packages/framework/tests/Unit/MarkdownFacadeTest.php b/packages/framework/tests/Unit/MarkdownFacadeTest.php index 88531f35744..88903630f90 100644 --- a/packages/framework/tests/Unit/MarkdownFacadeTest.php +++ b/packages/framework/tests/Unit/MarkdownFacadeTest.php @@ -12,6 +12,9 @@ */ class MarkdownFacadeTest extends UnitTestCase { + protected static bool $needsKernel = true; + protected static bool $needsConfig = true; + public function testRender(): void { $html = Markdown::render('# Hello World!');