File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed
tests/functional/Extension/Embed Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1515
1616use League \CommonMark \ConverterInterface ;
1717use League \CommonMark \Environment \Environment ;
18+ use League \CommonMark \Extension \Autolink \AutolinkExtension ;
1819use League \CommonMark \Extension \CommonMark \CommonMarkCoreExtension ;
1920use League \CommonMark \Extension \Embed \EmbedExtension ;
2021use League \CommonMark \MarkdownConverter ;
@@ -30,10 +31,17 @@ protected function createConverter(array $config = []): ConverterInterface
3031 {
3132 $ config ['embed ' ]['adapter ' ] = new FakeAdapter ();
3233
34+ $ enableAutolinkExtension = $ config ['enable_autolinks ' ] ?? false ;
35+ unset($ config ['enable_autolinks ' ]);
36+
3337 $ environment = new Environment ($ config );
3438 $ environment ->addExtension (new CommonMarkCoreExtension ());
3539 $ environment ->addExtension (new EmbedExtension ());
3640
41+ if ($ enableAutolinkExtension ) {
42+ $ environment ->addExtension (new AutolinkExtension ());
43+ }
44+
3745 return new MarkdownConverter ($ environment );
3846 }
3947
Original file line number Diff line number Diff line change 1+ < p > This is an embed:</ p >
2+ < iframe class ="embed " src ="https://www.youtube.com/watch?v=dQw4w9WgXcQ "> </ iframe >
3+ < p > So is this, with only three spaces of indentation:</ p >
4+ < iframe class ="embed " src ="https://www.youtube.com/watch?v=dQw4w9WgXcQ "> </ iframe >
5+ < p > This is not, because it's fully indented:</ p >
6+ < pre > < code > https://www.youtube.com/watch?v=dQw4w9WgXcQ
7+ </ code > </ pre >
8+ < p > This is not, because it has extra bits after the URL:</ p >
9+ < p > < a href ="https://www.youtube.com/watch?v=dQw4w9WgXcQ "> https://www.youtube.com/watch?v=dQw4w9WgXcQ</ a > <-- you gotta watch this!</ p >
10+ < p > This is not, because it's in a fenced code block:</ p >
11+ < pre > < code class ="language-md ">
12+ https://www.youtube.com/watch?v=dQw4w9WgXcQ
13+
14+ </ code > </ pre >
15+ < p > And this isn't either because it's inline: < img src ="https://www.youtube.com/watch?v=dQw4w9WgXcQ " alt ="" /> </ p >
16+ < p > Embeds can't be nested in other blocks:</ p >
17+ < ul >
18+ < li > https://www.youtube.com/watch?v=dQw4w9WgXcQ
19+ < ul >
20+ < li > https://www.youtube.com/watch?v=dQw4w9WgXcQ</ li >
21+ </ ul >
22+ </ li >
23+ </ ul >
24+ < p > This isn't valid because it's a lazy paragraph continuation:
25+ < a href ="https://www.youtube.com/watch?v=dQw4w9WgXcQ "> https://www.youtube.com/watch?v=dQw4w9WgXcQ</ a > </ p >
26+ < iframe class ="embed " src ="https://www.youtube.com/watch?v=dQw4w9WgXcQ "> </ iframe >
27+ < p > ^ This is fine, though</ p >
Original file line number Diff line number Diff line change 1+ ---
2+ enable_autolinks : true
3+ ---
4+
5+ This is an embed:
6+
7+ https://www.youtube.com/watch?v=dQw4w9WgXcQ
8+
9+ So is this, with only three spaces of indentation:
10+
11+ https://www.youtube.com/watch?v=dQw4w9WgXcQ
12+
13+ This is not, because it's fully indented:
14+
15+ https://www.youtube.com/watch?v=dQw4w9WgXcQ
16+
17+ This is not, because it has extra bits after the URL:
18+
19+ https://www.youtube.com/watch?v=dQw4w9WgXcQ <-- you gotta watch this!
20+
21+ This is not, because it's in a fenced code block:
22+
23+ ``` md
24+
25+ https://www.youtube.com/watch?v=dQw4w9WgXcQ
26+
27+ ```
28+
29+ And this isn't either because it's inline: ![ ] ( https://www.youtube.com/watch?v=dQw4w9WgXcQ )
30+
31+ Embeds can't be nested in other blocks:
32+
33+ - https://www.youtube.com/watch?v=dQw4w9WgXcQ
34+ - https://www.youtube.com/watch?v=dQw4w9WgXcQ
35+
36+ This isn't valid because it's a lazy paragraph continuation:
37+ https://www.youtube.com/watch?v=dQw4w9WgXcQ
38+
39+ https://www.youtube.com/watch?v=dQw4w9WgXcQ
40+ ^ This is fine, though
You can’t perform that action at this time.
0 commit comments