Skip to content

Commit

Permalink
Always render Markdown using the service
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jul 24, 2024
1 parent 612e3c3 commit 1860756
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
14 changes: 3 additions & 11 deletions packages/framework/src/Markdown/Models/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 3 additions & 0 deletions packages/framework/tests/Unit/MarkdownFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
Expand Down

0 comments on commit 1860756

Please sign in to comment.