22
33namespace App \Markdown ;
44
5+ use Embed \Embed ;
6+ use Embed \Http \Crawler ;
7+ use Embed \Http \CurlClient ;
58use Illuminate \Support \ServiceProvider ;
69use League \CommonMark \Environment \Environment ;
710use League \CommonMark \Extension \CommonMark \CommonMarkCoreExtension ;
@@ -17,6 +20,13 @@ class MarkdownServiceProvider extends ServiceProvider
1720 public function register (): void
1821 {
1922 $ 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+
2030 $ environment = new Environment ([
2131 'html_input ' => 'escape ' ,
2232 'max_nesting_level ' => 10 ,
@@ -34,8 +44,8 @@ public function register(): void
3444 'nofollow ' => ($ params ['nofollow ' ] ?? true ) ? 'external ' : '' ,
3545 ],
3646 'embed ' => [
37- 'adapter ' => new OscaroteroEmbedAdapter ,
38- 'allowed_domains ' => ['youtube.com ' ],
47+ 'adapter ' => new OscaroteroEmbedAdapter ( $ embed ) ,
48+ 'allowed_domains ' => ['youtube.com ' , ' twitter.com ' , ' x.com ' ],
3949 'fallback ' => 'link ' ,
4050 ],
4151 ]);
0 commit comments