File tree 4 files changed +8
-6
lines changed
4 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class MarkdownServiceProvider extends ServiceProvider
14
14
{
15
15
public function register (): void
16
16
{
17
- $ this ->app ->singleton (Converter::class, function () {
17
+ $ this ->app ->singleton (Converter::class, function ($ app , array $ params = [] ) {
18
18
$ environment = new Environment ([
19
19
'html_input ' => 'escape ' ,
20
20
'max_nesting_level ' => 10 ,
@@ -29,7 +29,9 @@ public function register(): void
29
29
'external_link ' => [
30
30
'internal_hosts ' => config ('app.host ' ),
31
31
'open_in_new_window ' => true ,
32
- 'nofollow ' => 'external ' ,
32
+ 'nofollow ' => ($ params ['nofollow ' ] ?? true ) ? 'external ' : '' ,
33
+ 'noreferrer ' => ($ params ['nofollow ' ] ?? true ) ? 'external ' : '' ,
34
+ 'noopener ' => ($ params ['nofollow ' ] ?? true ) ? 'external ' : '' ,
33
35
],
34
36
]);
35
37
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ public function body(): string
100
100
101
101
public function excerpt (int $ limit = 100 ): string
102
102
{
103
- return Str::limit (strip_tags (md_to_html ($ this ->body ())), $ limit );
103
+ return Str::limit (strip_tags (md_to_html ($ this ->body (), false )), $ limit );
104
104
}
105
105
106
106
public function hasHeroImageAuthor (): bool
Original file line number Diff line number Diff line change @@ -24,9 +24,9 @@ function is_active(mixed $routes): bool
24
24
/**
25
25
* Converts Markdown to a safe HTML string.
26
26
*/
27
- function md_to_html (string $ markdown ): string
27
+ function md_to_html (string $ markdown, bool $ nofollow = true ): string
28
28
{
29
- return app (App \Markdown \Converter::class)->toHtml ($ markdown );
29
+ return app (App \Markdown \Converter::class, [ ' nofollow ' => $ nofollow ] )->toHtml ($ markdown );
30
30
}
31
31
}
32
32
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ class="w-full bg-center bg-gray-800"
121
121
x-init =" $nextTick(function () { highlightCode($el); })"
122
122
class =" prose prose-lg text-gray-800 prose-lio"
123
123
>
124
- {!! md_to_html ($article -> body ()) ! !}
124
+ {!! md_to_html ($article -> body (), false ) ! !}
125
125
</div >
126
126
127
127
@if ($article -> isUpdated () )
You can’t perform that action at this time.
0 commit comments