2
2
3
3
namespace App \Markdown ;
4
4
5
+ use Embed \Embed ;
6
+ use Embed \Http \Crawler ;
7
+ use Embed \Http \CurlClient ;
5
8
use Illuminate \Support \ServiceProvider ;
6
9
use League \CommonMark \Environment \Environment ;
7
10
use League \CommonMark \Extension \CommonMark \CommonMarkCoreExtension ;
@@ -17,6 +20,13 @@ class MarkdownServiceProvider extends ServiceProvider
17
20
public function register (): void
18
21
{
19
22
$ this ->app ->singleton (Converter::class, function ($ app , array $ params = []) {
23
+ $ client = new CurlClient ();
24
+ $ client ->setSettings ([
25
+ // 'follow_location' => false,
26
+ ]);
27
+
28
+ $ embed = new Embed (new Crawler ($ client ));
29
+
20
30
$ environment = new Environment ([
21
31
'html_input ' => 'escape ' ,
22
32
'max_nesting_level ' => 10 ,
@@ -34,8 +44,8 @@ public function register(): void
34
44
'nofollow ' => ($ params ['nofollow ' ] ?? true ) ? 'external ' : '' ,
35
45
],
36
46
'embed ' => [
37
- 'adapter ' => new OscaroteroEmbedAdapter ,
38
- 'allowed_domains ' => ['youtube.com ' ],
47
+ 'adapter ' => new OscaroteroEmbedAdapter ( $ embed ) ,
48
+ 'allowed_domains ' => ['youtube.com ' , ' twitter.com ' , ' x.com ' ],
39
49
'fallback ' => 'link ' ,
40
50
],
41
51
]);
0 commit comments