Skip to content
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

[11.x] Add Support for Extensions in Str::markdown Method #51907

Merged
merged 3 commits into from
Jun 25, 2024
Merged
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
9 changes: 8 additions & 1 deletion src/Illuminate/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,19 @@ public static function words($value, $words = 100, $end = '...')
*
* @param string $string
* @param array $options
* @param array $extensions
* @return string
*/
public static function markdown($string, array $options = [])
public static function markdown($string, array $options = [], array $extensions = [])
{
$converter = new GithubFlavoredMarkdownConverter($options);

$environment = $converter->getEnvironment();

foreach ($extensions as $extension) {
$environment->addExtension($extension);
}
Comment on lines +645 to +649
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The environment is only needed when $extensions !== []. Wouldn't it make sense, to wrap this in an if?


return (string) $converter->convert($string);
}

Expand Down