Skip to content

Commit 2df0527

Browse files
authored
Merge pull request #1900 from hydephp/simplify-markdown-rendering-helper
[2.x] Update the `Markdown::render` method to always use the smart Markdown service
2 parents 612e3c3 + 2b6e40e commit 2df0527

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ This serves two purposes:
5757
- Reorganized and cleaned up the navigation and sidebar documentation for improved clarity.
5858
- Moved the sidebar documentation to the documentation pages section for better organization.
5959
- The build command now groups together all `InMemoryPage` instances under one progress bar group in https://github.com/hydephp/develop/pull/1897
60+
- 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
6061

6162
### Deprecated
6263
- for soon-to-be removed features.

packages/framework/src/Markdown/Models/Markdown.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Hyde\Markdown\Models;
66

77
use Hyde\Framework\Services\MarkdownService;
8-
use Hyde\Markdown\MarkdownConverter;
98
use Illuminate\Contracts\Support\Arrayable;
109
use Illuminate\Contracts\Support\Htmlable;
1110
use Illuminate\Support\HtmlString;
@@ -84,20 +83,13 @@ public static function fromFile(string $path): static
8483
/**
8584
* Render a Markdown string into HTML.
8685
*
87-
* If a source model is provided, the Markdown will be converted using the dynamic MarkdownService,
88-
* otherwise, the pre-configured singleton from the service container will be used instead.
86+
* If a source page class is provided, that class will be used to configure
87+
* the Hyde Markdown converter to enable features specific to that page.
8988
*
9089
* @return string $html
9190
*/
9291
public static function render(string $markdown, ?string $pageClass = null): string
9392
{
94-
if ($pageClass !== null) {
95-
return (new MarkdownService($markdown, $pageClass))->parse();
96-
} else {
97-
/** @var MarkdownConverter $converter */
98-
$converter = app(MarkdownConverter::class);
99-
100-
return (string) $converter->convert($markdown);
101-
}
93+
return (new MarkdownService($markdown, $pageClass))->parse();
10294
}
10395
}

packages/framework/tests/Feature/ColoredBlockquoteShortcodesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313
class ColoredBlockquoteShortcodesTest extends UnitTestCase
1414
{
15+
protected static bool $needsKernel = true;
16+
protected static bool $needsConfig = true;
17+
1518
public function testSignature()
1619
{
1720
$this->assertSame('>', ColoredBlockquotes::signature());

packages/framework/tests/Unit/MarkdownFacadeTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313
class MarkdownFacadeTest extends UnitTestCase
1414
{
15+
protected static bool $needsKernel = true;
16+
protected static bool $needsConfig = true;
17+
1518
public function testRender(): void
1619
{
1720
$html = Markdown::render('# Hello World!');

0 commit comments

Comments
 (0)