@@ -15,7 +15,12 @@ describe("heading-slugs", () => {
1515 . data ( "settings" , {
1616 fragment : true ,
1717 } )
18- . use ( [ rehypeParse , rehypeHeadingSlugs , rehypeStringify ] )
18+ . use ( [
19+ rehypeParse ,
20+ rehypeExternalLinks ,
21+ rehypeHeadingSlugs ,
22+ rehypeStringify ,
23+ ] )
1924 . process ( html ) ;
2025
2126 return file . toString ( ) ;
@@ -32,6 +37,16 @@ describe("heading-slugs", () => {
3237
3338 expect ( text ) . toMatchInlineSnapshot ( `"<h2 id="bar">foo</h2>"` ) ;
3439 } ) ;
40+
41+ test ( "does not add arrow if image children" , async ( ) => {
42+ const text = await process (
43+ '<h2 id="bar"><a href="https://example.com">foo</a></h2>' ,
44+ ) ;
45+
46+ expect ( text ) . toMatchInlineSnapshot (
47+ `"<h2 id="bar"><a href="https://example.com" target="_blank" rel="noopener">foo<span class="external-link"> ↗</span></a></h2>"` ,
48+ ) ;
49+ } ) ;
3550} ) ;
3651
3752describe ( "external-links" , ( ) => {
@@ -59,6 +74,16 @@ describe("external-links", () => {
5974
6075 expect ( text ) . toMatchInlineSnapshot ( `"<a href="/">foo</a>"` ) ;
6176 } ) ;
77+
78+ test ( "does not add arrow if image children" , async ( ) => {
79+ const text = await process (
80+ '<a href="https://example.com"><img src="/image.jpg" /></a>' ,
81+ ) ;
82+
83+ expect ( text ) . toMatchInlineSnapshot (
84+ `"<a href="https://example.com" target="_blank" rel="noopener"><img src="/image.jpg"></a>"` ,
85+ ) ;
86+ } ) ;
6287} ) ;
6388
6489describe ( "autolink-headings" , ( ) => {
0 commit comments