Skip to content

Replace Markdown::parse() with Markdown::render() #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ But since you could have a file with the same identifier in the `_posts` directo
The identifier property is closely related to the page model's route key property, which consists of the site output directory followed by the identifier.

### Added
- for new features.
- Added `render()` method to `Facades\Markdown`, replacing the `parse()` method of the same class

### Changed
- Breaking: Rename AbstractMarkdownPage constructor parameter `slug` to `identifier`
Expand All @@ -27,7 +27,7 @@ The identifier property is closely related to the page model's route key propert
- Makes some helpers in SourceFileParser public static allowing them to be used outside the class

### Deprecated
- for soon-to-be removed features.
- Deprecated `Facades\Markdown::parse()`, use `Facades\Markdown::render()` instead

### Removed
- for now removed features.
Expand Down
12 changes: 10 additions & 2 deletions packages/framework/src/Facades/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@
class Markdown
{
/**
* Parse a Markdown string into HTML.
* @deprecated v0.58.0-beta use Markdown::render() instead.
*/
public static function parse(string $markdown, ?string $sourceModel = null): string
{
return static::render($markdown, $sourceModel);
}

/**
* 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.
*
* @return string $html
*/
public static function parse(string $markdown, ?string $sourceModel = null): string
public static function render(string $markdown, ?string $sourceModel = null): string
{
return $sourceModel !== null
? (new MarkdownService($markdown, $sourceModel))->parse()
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Unit/MarkdownFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class MarkdownFacadeTest extends TestCase
{
public function test_parse(): void
public function test_render(): void
{
$markdown = '# Hello World!';

Expand Down