Skip to content
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
7 changes: 6 additions & 1 deletion src/Illuminate/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,15 +717,20 @@ public static function markdown($string, array $options = [], array $extensions
*
* @param string $string
* @param array $options
* @param array $extensions
* @return string
*/
public static function inlineMarkdown($string, array $options = [])
public static function inlineMarkdown($string, array $options = [], array $extensions = [])
{
$environment = new Environment($options);

$environment->addExtension(new GithubFlavoredMarkdownExtension());
$environment->addExtension(new InlinesOnlyExtension());

foreach ($extensions as $extension) {
$environment->addExtension($extension);
}

$converter = new MarkdownConverter($environment);

return (string) $converter->convert($string);
Expand Down
5 changes: 3 additions & 2 deletions src/Illuminate/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,12 @@ public function markdown(array $options = [], array $extensions = [])
* Convert inline Markdown into HTML.
*
* @param array $options
* @param array $extensions
* @return static
*/
public function inlineMarkdown(array $options = [])
public function inlineMarkdown(array $options = [], array $extensions = [])
{
return new static(Str::inlineMarkdown($this->value, $options));
return new static(Str::inlineMarkdown($this->value, $options, $extensions));
}

/**
Expand Down
13 changes: 13 additions & 0 deletions tests/Support/SupportStringableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,19 @@ public function testInlineMarkdown()
{
$this->assertEquals("<em>hello world</em>\n", $this->stringable('*hello world*')->inlineMarkdown());
$this->assertEquals("<a href=\"https://laravel.com\"><strong>Laravel</strong></a>\n", $this->stringable('[**Laravel**](https://laravel.com)')->inlineMarkdown());

$extension = new class implements ExtensionInterface
{
public bool $configured = false;

public function register(EnvironmentBuilderInterface $environment): void
{
$this->configured = true;
}
};

$this->stringable('# hello world')->inlineMarkdown([], [$extension]);
$this->assertTrue($extension->configured);
}

public function testMask()
Expand Down